Trouble with Stirling's formula

  • Thread starter Thread starter stepheckert
  • Start date Start date
  • Tags Tags
    Formula
Click For Summary
SUMMARY

The discussion centers on using Stirling's formula, specifically lnm!=mlnm-m+(1/2)ln(2πm), to calculate probabilities involving large factorials, such as determining the probability of getting exactly 500 heads and 500 tails when flipping 1000 coins. The user encounters overflow issues on their calculator when substituting Stirling's approximation into the probability formula N!/(n!(N-n)!)(p^n)(q^(N-n)). A solution involves simplifying the expression by combining exponential factors and expressing the result as e raised to a large negative power, ultimately leading to a manageable calculation.

PREREQUISITES
  • Understanding of Stirling's approximation
  • Familiarity with probability theory and binomial distributions
  • Basic knowledge of logarithmic functions
  • Experience with exponential functions and their properties
NEXT STEPS
  • Learn how to apply Stirling's approximation in probability calculations
  • Study the properties of logarithms and exponentials in mathematical computations
  • Explore numerical methods to handle large factorials without overflow
  • Investigate alternative probability distributions for large sample sizes
USEFUL FOR

Mathematicians, statisticians, and anyone involved in probability theory or combinatorial calculations, particularly those dealing with large datasets and factorial computations.

stepheckert
Messages
6
Reaction score
0
I am trying to solve for probabilities in systems with a large number of elements. To deal with the large factorials that appear in these formulas, I use Stirling's formula, lnm!=mlnm-m+(1/2)ln(2πm). My problem is that after I get the approximation and try to plug it into the probability formula, N!/(n!(N-n)!)(p^n)(q^(N-n)), I get overflows on my calculator. How can I get around this?

Here is an example problem:

Using Stirling's formula, calculate the probability of getting exactly 500 heads and 500 tails when flipping 1000 coins.

The probability equation looks like: (1000!/(2!998!))(1/2)^2(1/2)^998

I used lnm!=mlnm-m+(1/2)ln(2πm) to get: ln998!=5898.3 and ln1000!=5912.2

I wound up with somehting that looked like this: (e^5912.2/2e^5898.3)(1/2)^2(1/2)^998

How do I get my calculate to work with these kind of numbers??

Thanks for any help!
 
Physics news on Phys.org
stepheckert said:
Here is an example problem:

Using Stirling's formula, calculate the probability of getting exactly 500 heads and 500 tails when flipping 1000 coins.

The probability equation looks like: (1000!/(2!998!))(1/2)^2(1/2)^998

Looks like you switched from 500 heads and 500 tails to 998 heads and 2 tails (or 2 heads and 998 tails).
I used lnm!=mlnm-m+(1/2)ln(2πm) to get: ln998!=5898.3 and ln1000!=5912.2

I wound up with somehting that looked like this: (e^5912.2/2e^5898.3)(1/2)^2(1/2)^998

How do I get my calculate to work with these kind of numbers??

If you collect all of your factors of 2, you get 21001 in the denominator. Can you write that as e raised to some power? If so, you should be able to combine all of the exponential factors and express the answer as e raised to a large negative power.
 
The factor (1000!/(2! 998!)) can be reduced as follows:

1000! = 1000 * 999 * 998!

therefore (1000!/(2! 998!)) = 1000 * 999 * 998! / (2 * 998!) = 999000 / 2 = 499,500
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
8
Views
6K
Replies
14
Views
2K
Replies
2
Views
2K
Replies
1
Views
2K
Replies
3
Views
2K
  • · Replies 15 ·
Replies
15
Views
4K