Great catch!
You're absolutely right:
The sum of implied probabilities for the 15 remaining outcomes should always be less than the sum for all 16 outcomes, since you are removing a positive value from the sum.
Why did this happen?
The bug is in how the script calculates the "implied probability" for each 4-fight outcome.
It should be:
- For each of the 16 possible 4-fight outcomes, multiply the minimum implied probability for each fight's outcome (across all books), as was done for the best arbitrage.
- The sum of these 16 values is the total implied probability for the full parlay matrix.
- When you remove one outcome, the sum for the remaining 15 should be the total minus the implied probability of the excluded outcome.
But in the previous script, for the 15-outcome sum, it was recalculating the product for each outcome using the same book selection as the best arbitrage, which is not correct.
Each outcome should be constructed from the best available book for that specific outcome, not just the books used in the "best arbitrage" outcome.
Corrected Approach
- For each of the 16 possible outcomes, find the best (lowest) implied probability for that outcome (i.e., for each fight in the outcome, pick the best book for that outcome).
- Store all 16 outcome probabilities and their book selections.
- The total implied probability is the sum of all 16.
- For the "all favorites" and "all underdogs" outcomes, remove their value from the sum to get the 15-outcome sum.
- For the true probability, use the de-vigged probabilities for the excluded outcome.
Corrected Script
import itertools
NUM_FIGHTS = 5
NUM_BOOKS = 5
# Hardcoded odds (same structure: odds[fight][book][outcome])
odds = [
[
[2.00, 1.80],
[1.90, 1.90],
[2.10, 1.70],
[2.00, 1.80],
[1.95, 1.85]
],
[
[1.50, 2.50],
[1.60, 2.40],
[1.55, 2.45],
[1.50, 2.50],
[1.53, 2.47]
],
[
[1.80, 2.00],
[1.85, 1.95],
[1.70, 2.10],
[1.80, 2.00],
[1.75, 2.05]
],
[
[2.20, 1.60],
[2.10, 1.70],
[2.30, 1.55],
[2.20, 1.60],
[2.15, 1.65]
],
[
[1.40, 2.80],
[1.45, 2.70],
[1.35, 2.90],
[1.40, 2.80],
[1.42, 2.75]
]
]
def compute_implied_probability(decimal_odds):
return 1.0 / decimal_odds if decimal_odds > 0 else 0.0
def de_vig_fight(book_odds):
p1 = 1.0 / book_odds[0]
p2 = 1.0 / book_odds[1]
total = p1 + p2
return p1 / total, p2 / total
def get_best_parlay_matrix(fight_indices):
# For each of the 16 outcomes, find the best (lowest) implied probability parlay
outcome_matrix = []
for outcome in itertools.product([0, 1], repeat=4):
parlay_prob = 1.0
parlay_books = []
for i, fight_idx in enumerate(fight_indices):
outcome_idx = outcome[i]
# For this fight and outcome, find the best book
best_prob = float('inf')
best_book = None
for book_idx in range(NUM_BOOKS):
prob = compute_implied_probability(odds[fight_idx][book_idx][outcome_idx])
if prob < best_prob:
best_prob = prob
best_book = book_idx
parlay_prob *= best_prob
parlay_books.append(best_book)
outcome_matrix.append({
"outcome": outcome,
"parlay_prob": parlay_prob,
"parlay_books": parlay_books
})
return outcome_matrix
def calculate_true_probability(fight_indices, outcome, parlay_books):
true_prob = 1.0
for i, fight_idx in enumerate(fight_indices):
outcome_idx = outcome[i]
book_idx = parlay_books[i]
book_odds = odds[fight_idx][book_idx]
true_prob0, true_prob1 = de_vig_fight(book_odds)
true_prob *= true_prob0 if outcome_idx == 0 else true_prob1
return true_prob
def main():
best_total = float('inf')
best_fight_indices = None
best_matrix = None
# Try all 4-fight combinations
for fight_indices in itertools.combinations(range(NUM_FIGHTS), 4):
matrix = get_best_parlay_matrix(fight_indices)
total = sum(x["parlay_prob"] for x in matrix)
if total < best_total:
best_total = total
best_fight_indices = fight_indices
best_matrix = matrix
print(f"Best arbitrage 4-fight set: {best_fight_indices}")
print(f"Total implied probability (16 outcomes): {best_total:.4f}")
# Find all-favorites and all-underdogs outcomes
all_favorites = tuple(0 for _ in range(4))
all_underdogs = tuple(1 for _ in range(4))
# Find their entries in the matrix
fav_entry = next(x for x in best_matrix if x["outcome"] == all_favorites)
dog_entry = next(x for x in best_matrix if x["outcome"] == all_underdogs)
# Remove each and sum the rest
fav_sum = sum(x["parlay_prob"] for x in best_matrix if x["outcome"] != all_favorites)
dog_sum = sum(x["parlay_prob"] for x in best_matrix if x["outcome"] != all_underdogs)
# Calculate true probabilities for the excluded outcomes
fav_true_prob = calculate_true_probability(best_fight_indices, all_favorites, fav_entry["parlay_books"])
dog_true_prob = calculate_true_probability(best_fight_indices, all_underdogs, dog_entry["parlay_books"])
print("\nScenario 1: Removing all-favorites outcome")
print(f"Excluded outcome: {all_favorites}")
print(f"Implied probability of excluded outcome: {fav_entry['parlay_prob']:.6f}")
print(f"Sum of implied probabilities (15 outcomes): {fav_sum:.6f}")
print(f"True probability of excluded outcome: {fav_true_prob:.6f}")
print("\nScenario 2: Removing all-underdogs outcome")
print(f"Excluded outcome: {all_underdogs}")
print(f"Implied probability of excluded outcome: {dog_entry['parlay_prob']:.6f}")
print(f"Sum of implied probabilities (15 outcomes): {dog_sum:.6f}")
print(f"True probability of excluded outcome: {dog_true_prob:.6f}")
if __name__ == "__main__":
main()
Key Fixes:
- Each outcome's parlay is constructed from the best book for each leg, not just the books from the "best arbitrage" outcome.
- The sum for 15 outcomes is now always less than the sum for 16.
- True probability for the excluded outcome is calculated using the actual books used for that outcome.
This will now always show the correct relationship:
sum_15 = sum_16 - implied_prob_of_excluded_outcome
- and the true probability is calculated for the excluded outcome using de-vigged probabilities.
Let me know if you want to see the output for your specific odds!