Two archers, Ashley and Chamath, have decided to compete with each other and agreed to shoot 50 times each. The winner will be the one who hits the target more times than the other.
Given that Ashley shoots with 40% accuracy and Chamath with 50% accuracy, what is the probability, in percent, that Ashley wins? Round your answer to three decimal places.
Hint: You should write simple code to speed up your calculations.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Yesterday, in school, a good friend of mine asked me to help her with solving this exact problem where total number of hits was 2. Solution was pretty straightforward. Win for A would mean one of the following results ( 1 , 0 ) , ( 2 , 0 ) or ( 2 , 1 ) . The final probability is the sum of the probabilities of these results: P ( Ashley wins ) = ( 1 2 ) ⋅ 0 . 4 1 ⋅ 0 . 6 1 ⋅ ( 0 2 ) ⋅ 0 . 5 2 + ( 2 2 ) ⋅ 0 . 4 2 ⋅ ( 0 2 ) ⋅ 0 . 5 2 + ( 2 2 ) ⋅ 0 . 4 2 ⋅ ( 1 2 ) ⋅ 0 . 5 2 = 0 . 2 4 Yet, I was still left wondering if I can generalize my solution and evaluate the same probability for number of shootings greater than 2, for any n , so, while I was walking back home, I gave some thought to it. The first thing I realized I had to do was to somehow categorize all winning results in an efficient way that will enable me to calculate and sum their probabilities. I began by classifying the winning results according to the difference ( d ) between Ashley's and Chamath's accurate hits. If number of Ashley's accurate hits is denoted with a and Chamath's with c , it follows that:
Now, notice how each possible winning result is defined. Probability of result ( a , c ) out of n hits is: ( a n ) p a ( 1 − p ) n − a ( c n ) q c ( 1 − q ) n − c , where p and q are accuracies of Ashley and Chamath, respectively. We can now evaluate the final probability: P ( Ashley wins ) = d = 1 ∑ n a = d ∑ n ( a n ) p a ( 1 − p ) n − a ( a − d n ) q a − d ( 1 − q ) n − a + d . Unfortunately, from here, expression cannot be substantially simplified, so I wrote a simple function in Python to carry out calculations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Input :
1 2 |
|
Output :
1 |
|
That's desired solution, but it would be interesting to see how the probability varies relative to n .
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Here's the graph I got: n = 5 and it equals 0 . 2 6 0 4 2 .
It turns out that the peak of graph (maximum probability) occurs atActually, it's also fun to alter values of p and q and examine corresponding graphs. Here's another one, for p = 0 . 3 and q = 0 . 3 : We can see that the probability slowly tends to 0 . 5 as n goes to ∞ . No matter how big or small accuracies are, as long as they are equal, this will be true. That's somewhat intuitive because as the number of total hits rises, it is more and more unlikely that they both had the same number of accurate hits resulting in a draw. Feel free to copy my code and paste it to your coding environment and explore the behavior of the function with other values of p and q .
Problem Loading...
Note Loading...
Set Loading...
Why code? The cumulative standard normal distribution is a good approximation.
With a 50 shots, the number of hits of each player may be approximated by a normal distribution with μ = 5 0 α , σ 2 = 5 0 α ( 1 − α ) . To determine who wins, we subtract Ashleys's number of hits from Chamath's number of hits. Thus we study the random variable X = C − A , which is approximately normally distributed with parameters μ X = μ C − μ A = 5 0 ⋅ 0 . 5 − 5 0 ⋅ 0 . 4 = 2 5 − 2 0 = 5 ; σ X 2 = σ C 2 + σ A 2 = 5 0 ⋅ 0 . 5 ⋅ 0 . 5 + 5 0 ⋅ 0 . 4 ⋅ 0 . 6 = 1 2 2 1 + 1 2 = 2 4 2 1 . At first, one may think that Ashley is the winner iff X < 0 ; however, we must account for the possibility of a tie, which in our continuous approximation would correspond to − 2 1 < X < 2 1 . Therefore we calculate P ( X < − 2 1 ) = Φ ⎝ ⎛ 2 4 2 1 2 1 − 5 ⎠ ⎞ = Φ ( − 1 . 1 1 1 2 ) = 0 . 1 3 3 2 . Here, Φ is the cumulative probability distribution (probability function) of the standard normal distribution.
This answer, 1 3 . 3 2 % is not exact due to the normal approximation of the binomial distribution, but close enough.
Okay, let's do some coding
We must calculate 0 ≤ k < j ≤ N ∑ ( j N ) ( 1 − α ) N − j α j ( k N ) ( 1 − β ) N − k β k , which may be written as i = 0 ∑ N ( i N ) ( 1 − α ) N − i α i C i − 1 with C i − 1 = k = 0 ∑ i − 1 ( k N ) ( 1 − β ) N − k β k . Here is how.
Note that we only use a single loop. In this loop,
binom
= ( i N ) .powA
= ( 1 − α ) N − j α j andpowC
= ( 1 − β ) N − i β i .pA
andpC
= probabilities that Ashley/Chamath have i hits.cumC
= C i − 1 = probability that Chamath has fewer than i hits.