Old Jimmy and young Pete are both tennis champions. They have played each other many times, each winning exactly half of the matches. When both are fresh Jimmy is much the better player, but he tires rapidly so his probability of winning the kth set is p
k, where p is the probability that he wins the first set.
If they always play best-of-five matches, what is the value of p?
[Edit: this is incorrect; I correctly solved the equation below, but it is the wrong equation]
Goal: find p such that p^1 + p^2 + p^3 + p^4 + p^5 = 2.5
Wolfram Alpha: 0.777307
Spreadsheet goal seek:
1 0.777306976482763 <-- approximate answer
2 0.604206135688774
3 0.469653644504575
4 0.365065054403961
5 0.283767613658258
0.499999884947666 (average with goal seek 0.5)
I previously wrote a program to find the zeros of a polynomial using the Newton-Raphson method:
result = 0.7773070477563763
Program output
Estimate for p, using Newton-Raphson 0.7773070477563763
Average for 5 sets 0.5
(But I am not sure to what precision level these are accurate beyond the first 6 places)
"""
def pwin(p):
ans = 0
for k in range(1,6):
ans += p**k
return ans/5
def findzero(poly,lo= -100000,hi= +100000):
""" poly is a list of coefficients of a polynomial and lo and hi are limits
on where to look for a zero of the function
e.g poly = [1,4,3,6] means x^3 + 4x^2 + 3x + 6
Use Newton-Raphson method """
revPoly = poly[::-1]
guess = lo
revDeriv = []
for i,v in enumerate(revPoly):
if i == 0:
continue
revDeriv.append(i*v)
def f(x):
ans = 0
for i,v in enumerate(revPoly):
ans += v*x**i
return ans
def fPrime(x):
ans = 0
for i,v in enumerate(revDeriv):
ans += v*x**i
return ans
finished = False
while not finished:
error = abs(f(guess)/fPrime(guess))
guess = guess - f(guess)/fPrime(guess)
if error < 10** -10:
finished = True
return guess
p_estimate = findzero([1,1,1,1,1,-2.5])
print('Estimate for p, using Newton-Raphson', p_estimate )
print('Average for 5 sets', pwin(p_estimate) )
Edited on December 29, 2023, 3:06 pm
|
Posted by Larry
on 2023-12-29 11:52:55 |