This question is based around a game I made in python, based on the racket sport, Squash. Basically simulation of games inside the code take the two ability ratings, one from player a, one from player b, and uses this probability formula to calculate the winner:
p = ra/(ra+rb)
Where p(probability), ra(rating of player a), rb(rating of player b)
Here are two of the main functions I've created in my code, just to give you some context as to how the game works:
def game(ra, rb):
"simulates a single game and returns scores"
p = ra/(ra+rb) #Calculating the probability that player A wins a point
score = [0,0]
while(((max(score)>10) & ((max(score)-2)<min(score))) or ((max(score)<11))):
r = uniform(0,1)
if r < p:
score[0]+=1
else:
score[1]+=1
else:
return((score[0],score[1]))
def winProbability(ra, rb, n):
"simulates n number of games and returns probability based on results"
p = 0.5
wins = [0,0]
for i in range(n):
curgame = game(ra,rb)
if (curgame[0] > curgame[1]):
wins[0]+=1
else:
wins[1]+=1
if (max(wins)>0):
p = wins[0]/(wins[0]+wins[1])
return p
The question: Suppose player a has ability 60 and player b has ability 40, and they play a match where the winner is the first player to win n games. What is the smallest value of n such that the probability that a wins the match is at least 0.9? You may answer using simulation, theory, or a combination of both.
If you don't understand the code that's fine, It's the maths way around finding out this answer that i'm interested in most. I've already tried creating a loop of simulating games which has currently been running for 30 minutes and just reached 0.837 (rounded), so I know for a fact this method is way to long. I'm unsure of what equation would be needed to solve this problem?
The approximate methods described by other solutions certainly narrow the computation down a lot. It is likely, of course, that an approximate answer is satisfactory. To do the calculation exactly: if you seek $n$ wins, play out all of the $2n-1$ games. In such a series, the winning team will be the only team to have won at least $n$. If you favored team wins each game with probability $p$ then the probability that they will win the series is $$P_n=\sum_{i=n}^{2n-1}\binom {2n-1}ip^i(1-p)^{2n-1-i}$$
Taking $p=.6$ for your problem, we compute (with mechanical assistance) that $$P_{20}=0.897941369\quad \&\quad P_{21}=0.903482784$$ Thus you need $21$ games to clear the $.9$ hurdle.