Binomial distribution

  • Thread starter Manel
  • Start date
  • #1
10
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?
 

Answers and Replies

  • #2
statdad
Homework Helper
1,495
35
Log p? I'm not sure what expression it is you calculated the log of. Try this:
Since
[tex] \binom{100}{50} = \dfrac{100!}{50! \cdot 50!}
[/tex]
its logarithm is
[tex]
\log{100!} - \log{50! \cdot 50!} = \log{100!} - \left(\log 50! + \log 50!\right) = \log{100!} - 2\log{50!}
[/tex]

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 ...
 
  • #3
Orodruin
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
16,820
6,638
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:
  • #4
10
0
Log p? I'm not sure what expression it is you calculated the log of. Try this:
Since
[tex] \binom{100}{50} = \dfrac{100!}{50! \cdot 50!}
[/tex]
its logarithm is
[tex]
\log{100!} - \log{50! \cdot 50!} = \log{100!} - \left(\log 50! + \log 50!\right) = \log{100!} - 2\log{50!}
[/tex]

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
 
  • #5
10
0
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π !!!!
 
  • #6
Orodruin
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
16,820
6,638
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.
 
  • #7
10
0
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
 
  • #8
10
0
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)?
 
  • #9
Orodruin
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
16,820
6,638
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
Ray Vickson
Science Advisor
Homework Helper
Dearly Missed
10,706
1,728
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!##:
[tex] \text{St}(n) < n! < \text{St1}(n) \\
\text{where} \\
\text{St}(n) = \sqrt{2 \pi n} n^n e^{-n}, \;
\text{St1}(n) = \sqrt{2 \pi n} n^n e^{-n + \frac{1}{12n}}
[/tex]
If we call St1(n) the corrected Stirling, it gives much better accuracy, even for small ##n##:
[tex]
\begin{array}{cccc}
n & n! & \text{Stirling} & \text{Corrected Stirling}\\
1 & 1 & 0.922137 & 1.002274\\
2 & 2 & 1.919004 & 2.000652 \\
5 & 120 & 118.0192 & 120.0026 \\
10 & 3628800 & 3598696 & 3628810 \\
15 & 1.307674e+12 & 1.300431e+12 & 1.307675e+12 \\
20 & 2.432902e+18 & 2.422787e+18 & 2.432903e+18 \\
25 & 1.551121e+25 & 1.545959e+25 & 1.551121e+25 \\
30 & 2.652529e+32 & 2.645171e+32 & 2.652529e+32
\end{array}
[/tex]
Note that
[tex] \log(\text{St1}(n)) = \frac{1}{2} \log(2 \pi) +\frac{1}{2} \log(n) + n \log(n) - n + \frac{1}{12n} [/tex]
Was that the "correction" you cited?
 
  • Like
Likes Manel
  • #11
10
0
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!##:
[tex] \text{St}(n) < n! < \text{St1}(n) \\
\text{where} \\
\text{St}(n) = \sqrt{2 \pi n} n^n e^{-n}, \;
\text{St1}(n) = \sqrt{2 \pi n} n^n e^{-n + \frac{1}{12n}}
[/tex]
If we call St1(n) the corrected Stirling, it gives much better accuracy, even for small ##n##:
[tex]
\begin{array}{cccc}
n & n! & \text{Stirling} & \text{Corrected Stirling}\\
1 & 1 & 0.922137 & 1.002274\\
2 & 2 & 1.919004 & 2.000652 \\
5 & 120 & 118.0192 & 120.0026 \\
10 & 3628800 & 3598696 & 3628810 \\
15 & 1.307674e+12 & 1.300431e+12 & 1.307675e+12 \\
20 & 2.432902e+18 & 2.422787e+18 & 2.432903e+18 \\
25 & 1.551121e+25 & 1.545959e+25 & 1.551121e+25 \\
30 & 2.652529e+32 & 2.645171e+32 & 2.652529e+32
\end{array}
[/tex]
Note that
[tex] \log(\text{St1}(n)) = \frac{1}{2} \log(2 \pi) +\frac{1}{2} \log(n) + n \log(n) - n + \frac{1}{12n} [/tex]
Was that the "correction" you cited?
So the corrected stirling is the most accurate formula to use if we want better precision?
 
  • #12
Ray Vickson
Science Advisor
Homework Helper
Dearly Missed
10,706
1,728
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
Ray Vickson
Science Advisor
Homework Helper
Dearly Missed
10,706
1,728
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

Related Threads on Binomial distribution

  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
2
Views
730
  • Last Post
Replies
1
Views
987
  • Last Post
Replies
1
Views
4K
  • Last Post
Replies
1
Views
797
  • Last Post
Replies
11
Views
5K
  • Last Post
Replies
1
Views
762
Top