Trouble with Stirling's formula

  • Thread starter Thread starter stepheckert
  • Start date Start date
  • Tags Tags
    Formula
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
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.