Probabilities of Getting 50 Tails in 100 Coin Tosses Using Binomial Distribution

AI Thread Summary
The discussion focuses on calculating the probability of getting 50 tails in 100 coin tosses using the binomial distribution. The initial approach involved using Stirling's approximation for factorials, but it was noted that this method lacks accuracy for this problem. Participants suggested using a corrected version of Stirling's formula for better precision, which includes additional terms for logarithmic approximations. The final probability was calculated to be approximately 0.08 after addressing algebraic errors and clarifying the correct application of Stirling's approximation. The conversation highlights the importance of accuracy in statistical calculations, especially when dealing with large numbers.
Manel
Messages
10
Reaction score
0

Homework Statement


You throw a coin a 100 times, what's the probability of getting 50 tails?

Homework Equations


1d53e4a0d17e17adfeb7f53ecca9df5d.png

977b495e5d962b18db3c56fdabf2cbc6.png


The Attempt at a Solution


We have n=100 , p=1/2, q=1/2 and k=50 we substitute in the first equation we get:
P= 100!/ (50! * 50!) * (1/2)^100
The factorials are not simple to calculate so i used Stirling formula ( logarithmic approximation) and i found that Log P=0 so P=1 which i think is incorrect because 1 is the sum of all the probabilities...so where is my mistake?
 
Physics news on Phys.org
Log p? I'm not sure what expression it is you calculated the log of. Try this:
Since
\binom{100}{50} = \dfrac{100!}{50! \cdot 50!}<br />
its logarithm is
<br /> \log{100!} - \log{50! \cdot 50!} = \log{100!} - \left(\log 50! + \log 50!\right) = \log{100!} - 2\log{50!}<br />

use the approximation to work that out, then go back and finish the calculation. (Or, you can use Wolfram Alpha to get the coefficient). It is possible that the intent of the problem is to use the normal approximation, but unless that is specifically requested ...
 
I suggest not using the Stirling formula. Computing those factorials relatively accurately should not be a big problem for a computer.

Edit: To clarify, the Stirling formula is not accurate enough for this problem. In order to get something more reasonable you need to include the next term of the approximation as well:
$$
\ln(n!) \simeq n(\ln n - 1) + \frac 12 \ln(2\pi n)
$$
 
Last edited:
statdad said:
Log p? I'm not sure what expression it is you calculated the log of. Try this:
Since
\binom{100}{50} = \dfrac{100!}{50! \cdot 50!}<br />
its logarithm is
<br /> \log{100!} - \log{50! \cdot 50!} = \log{100!} - \left(\log 50! + \log 50!\right) = \log{100!} - 2\log{50!}<br />

use the approximation to work that out, then go back and finish the calculation. (Or, you can use Wolfram Alpha to get the coefficient). It is possible that the intent of the problem is to use the normal approximation, but unless that is specifically requested ...

That's exactly what i did but in order to get that i had to introduce the Log in both sides of the equation, that's why i got Log P
 
Orodruin said:
I suggest not using the Stirling formula. Computing those factorials relatively accurately should not be a big problem for a computer.

Edit: To clarify, the Stirling formula is not accurate enough for this problem. In order to get something more reasonable you need to include the next term of the approximation as well:
$$
\ln(n!) \simeq n(\ln n - 1) + \frac 12 \ln(2\pi n)
$$
I used the next term too and i got a negative result ! I got 1/2 Log2 - 1/2 Log 100π !
 
Then I suggest you redo the algebra. The ##100\log(1/2)## term should cancel with the leading terms from the Stirling approximation and you should be left with the correction terms from ##\ln(100!)## and ##2\ln(50!)##. Do note that the result for ##\ln(P)## should be negative as long as the probability is smaller than 1. I tried this problem both by computing the factorials and by using the correction to the Stirling formula. Both gave similar results.
 
Orodruin said:
Then I suggest you redo the algebra. The ##100\log(1/2)## term should cancel with the leading terms from the Stirling approximation and you should be left with the correction terms from ##\ln(100!)## and ##2\ln(50!)##. Do note that the result for ##\ln(P)## should be negative as long as the probability is smaller than 1. I tried this problem both by computing the factorials and by using the correction to the Stirling formula. Both gave similar results.
oh yes yes that's ok i found P=0.08 ...that was Log P which is negative sorry ...Thank you
 
Orodruin said:
I suggest not using the Stirling formula. Computing those factorials relatively accurately should not be a big problem for a computer.

Edit: To clarify, the Stirling formula is not accurate enough for this problem. In order to get something more reasonable you need to include the next term of the approximation as well:
$$
\ln(n!) \simeq n(\ln n - 1) + \frac 12 \ln(2\pi n)
$$
Just a question, How can we know that we should get to next term of the approximation ( without calculating and finding a wrong result)?
 
A priori we do not. In order to know we must know how the next term in the series behaves (in this case as ln(n)) and compare to the contribution of the previous terms. The thing to note here is that as was the case in this problem, terms from different contributions might cancel out to leading order and then you really have to go to the next order in the expansion. Another example of this would be ##f(x) = e^x - e^{-x}## for small ##x##. In that situation we would have ##f(x) \simeq 0## close to ##x = 0## due to ##e^x \simeq 1##. However, as soon as you go to the first order correction, you would obtain ##e^x \simeq 1+x## and thus
$$
f(x) \simeq (1+x) - (1-x) = 2x.
$$
 
  • Like
Likes Manel
  • #10
Manel said:
Just a question, How can we know that we should get to next term of the approximation ( without calculating and finding a wrong result)?

I'm not sure what your "next term" would be, but there is a very simple correction to Stirling that gives an upper bound on ##n!##:
\text{St}(n) &lt; n! &lt; \text{St1}(n) \\<br /> \text{where} \\<br /> \text{St}(n) = \sqrt{2 \pi n} n^n e^{-n}, \; <br /> \text{St1}(n) = \sqrt{2 \pi n} n^n e^{-n + \frac{1}{12n}}<br />
If we call St1(n) the corrected Stirling, it gives much better accuracy, even for small ##n##:
<br /> \begin{array}{cccc}<br /> n &amp; n! &amp; \text{Stirling} &amp; \text{Corrected Stirling}\\<br /> 1 &amp; 1 &amp; 0.922137 &amp; 1.002274\\<br /> 2 &amp; 2 &amp; 1.919004 &amp; 2.000652 \\<br /> 5 &amp; 120 &amp; 118.0192 &amp; 120.0026 \\<br /> 10 &amp; 3628800 &amp; 3598696 &amp; 3628810 \\<br /> 15 &amp; 1.307674e+12 &amp; 1.300431e+12 &amp; 1.307675e+12 \\<br /> 20 &amp; 2.432902e+18 &amp; 2.422787e+18 &amp; 2.432903e+18 \\<br /> 25 &amp; 1.551121e+25 &amp; 1.545959e+25 &amp; 1.551121e+25 \\<br /> 30 &amp; 2.652529e+32 &amp; 2.645171e+32 &amp; 2.652529e+32<br /> \end{array}<br />
Note that
\log(\text{St1}(n)) = \frac{1}{2} \log(2 \pi) +\frac{1}{2} \log(n) + n \log(n) - n + \frac{1}{12n}
Was that the "correction" you cited?
 
  • Like
Likes Manel
  • #11
Ray Vickson said:
I'm not sure what your "next term" would be, but there is a very simple correction to Stirling that gives an upper bound on ##n!##:
\text{St}(n) &lt; n! &lt; \text{St1}(n) \\<br /> \text{where} \\<br /> \text{St}(n) = \sqrt{2 \pi n} n^n e^{-n}, \;<br /> \text{St1}(n) = \sqrt{2 \pi n} n^n e^{-n + \frac{1}{12n}}<br />
If we call St1(n) the corrected Stirling, it gives much better accuracy, even for small ##n##:
<br /> \begin{array}{cccc}<br /> n &amp; n! &amp; \text{Stirling} &amp; \text{Corrected Stirling}\\<br /> 1 &amp; 1 &amp; 0.922137 &amp; 1.002274\\<br /> 2 &amp; 2 &amp; 1.919004 &amp; 2.000652 \\<br /> 5 &amp; 120 &amp; 118.0192 &amp; 120.0026 \\<br /> 10 &amp; 3628800 &amp; 3598696 &amp; 3628810 \\<br /> 15 &amp; 1.307674e+12 &amp; 1.300431e+12 &amp; 1.307675e+12 \\<br /> 20 &amp; 2.432902e+18 &amp; 2.422787e+18 &amp; 2.432903e+18 \\<br /> 25 &amp; 1.551121e+25 &amp; 1.545959e+25 &amp; 1.551121e+25 \\<br /> 30 &amp; 2.652529e+32 &amp; 2.645171e+32 &amp; 2.652529e+32<br /> \end{array}<br />
Note that
\log(\text{St1}(n)) = \frac{1}{2} \log(2 \pi) +\frac{1}{2} \log(n) + n \log(n) - n + \frac{1}{12n}
Was that the "correction" you cited?
So the corrected stirling is the most accurate formula to use if we want better precision?
 
  • #12
Manel said:
So the corrected stirling is the most accurate formula to use if we want better precision?
I would not bother in this problem: P0 = 0.07958923737, P1 = 0.07978845606 and P2 = 0.07958923413, where P0 = exact, P1 uses Stirling and P2 uses corrected Stirling. To 3 digits we have P0 = 0.0796, P1 = 0.0798 and P2 = 0.0796.

The differences would be more significant in smaller problems, such as for n near 20 instead of 100.
 
  • Like
Likes Manel
  • #13
Manel said:
So the corrected stirling is the most accurate formula to use if we want better precision?

I just realized that what you call "Stirling" and what I call "Stirling" are very different. Your Stirling is essentially ##\log(n!) \sim n \log(n) - n##, which is true, but fails when exponentiated: ## n ! \not\sim n^n e^{-n}## ! What I (and essentially all modern textbooks) call Stirling is ##\log(n!) \sim \frac{1}{2} \log(2 \pi) + \frac{1}{2} \log(n) + n \log(n) - n##. That is true, and also leads to a true result when exponentiated: ##n! \sim \sqrt{2 \pi n} n^n e^{-n}##. What I called the "corrected" Stirling gives results that are even better.

So, when I said it would be OK to use Stirling (uncorrected) I meant the standard Stirling that includes the ##\sqrt{2 \pi n}## factor, not your "bad" Stirling that omits it!
 
  • Like
Likes Manel
Back
Top