I have seen plenty of questions (normally focussing on a best of 7 baseball scenario), which look at the probability of either team A winning given x % chance in each game or what is the probability the series goes the full 7 matches.
However I wanted to try and create a Python function for this (I'm not asking for help with the syntax in case that's not allowed, I'm just after the mathematical logic):
def calc_win_probability(n, p_a, p_b=False):
if p_b is False:
p_b = 1-p_a
g = ceil(n/2)
prob_list = []
for i in range(g,n+1):
a = (comb(i,g-1) * pow(p_a,g-1) * pow(p_b,(i - (g-1)))) * p_a
b = (comb(i,g-1) * pow(p_b,g-1) * pow(p_a,(i - (g-1)))) * p_b
prob_list.append({'games': i, 'prob_a_win': a, 'prob_b_win': b, 'combined_prob': a+b})
return {'overall_prob': sum([p['combined_prob'] for p in prob_list]) ,'prob_list': prob_list}
The overall probability increases as n increases, so that makes me question whether my logic is flawed as conceptually that feels wrong (but perhaps I'm missing the obvious and it shouldn't equal 1 as certain scenarios are ignored)?
My assumptions are as follows:
- The probability of either team winning any given game doesn't change regardless of the situation
- The series ends once one team reaches a given number of games (e.g. 4/7, 3/5 etc.)
- My logic here is focused on the number of games to win, not number of games in the series, so the following:
- b = (comb(i,g-1) * pow(p_b,g-1) * pow(p_a,(i - (g-1)))) * p_b is, for example after 6 games: (6nCr3 * 0.4^3 * 0.6^3) * 0.4
The approach I came up with was based on suggestions I've seen on here, however I'm unsure if my logic is 100% correct as some people have suggested that you don't need to factor in the games not played and should only consider the probability of a given team winning within the 7 matches.
Now to complicate things further, what I actually wanted to do was take this concept (if my above logic is correct) and then try to consider (as this is more realistic):
If it is not known the % chance each team has got of winning a match, but you can derive a probability a team will win the series (lets assume a model exists and is accurate for now), how can you then apply this to work out how the percentage chance changes as the series goes by?
So for example, if team A has a 60% of winning the series at the start, but the score is 2-1 after 3 games how much has their percentage chance of a series win increased?
However before I can attempt that I'm worried my initial logic is incorrect, so if someone is able to kindly clarify whether my first attempt is sensible, I can then attempt stage 2 and hopefully post the approach to that?
I am not clear as to what you are driving at.
There are two ways of computing how a team say $A$ with a probability p for winning a game can win (say) a $5$ game tournament.
The first applies the negative binomial and will compute P(A wins in exactly $3$ games) + P(A wins in exactly $4$ games) + P(wins in exactly $5$ games)
The formula would be $\dbinom2 0q^0p^3 + \dbinom3 1 q^1p^3 + \dbinom 4 2 q^2p^3 \;\;= p^3(1 +3q + 6q^2)$
But a simpler way is to consider the full tournament, realizing that $A$ is guaranteed to win if $A$ loses $<=2$ games, and the formula is
$\dbinom 5 0 q^0p^5 +\dbinom 5 1 q^1p^4 + \dbinom 5 2 q^2p^3) \;\;= p^3(p^2 + 5pq + 10q^2)$
The two formulas are apparently different, but you should be able to prove that they are equal.
So I don't know what is troubling you, what is the "twist"