Stirling's Approximation for a probability distribution

379 Views Asked by At

I have a probability distibution: $$Pr(n_E) =\frac{1}{4^S}\frac{(2 S)!}{(S-n_E)! (S +n_E)!}$$ To simplfy this into something useful, I take the log of the probability and use Stirling's approximation, which is $$\ln\left[x!\right]\to x\ln\left[x\right] - x$$ when x is sufficiently large. $$\begin{align} \ln\left[Pr(n_E)\right] &= \ln\left[\frac{1}{4^S}\frac{(2 S)!}{(S-n_E)! (S +n_E)!}\right]\\ &=\ln\left[(2S)!\right] - \ln\left[(S-n_E)!\right] - \ln\left[(S+n_E)!\right] - S\ln\left[4\right]\\\\ &\hspace{1cm}\text{Using Sterling's approximation}\\\\ &=\left(\begin{aligned} &2S\ln\left[2S\right] -2S - (S-n_E)\ln\left[S-n_E\right] + (S-n_E)\\ &\hspace{0.5cm} - (S+n_E)\ln\left[S+n_E\right] + (S+n_E) - S\ln\left[4\right] \end{aligned}\right)\\ &=2S\ln\left[2S\right] - (S-n_E)\ln\left[S-n_E\right] - (S+n_E)\ln\left[S+n_E\right] - S\ln\left[4\right] \end{align}$$ However, plotting the probability distribution before and after using Stirling's approximation yields extremely different amplitudes. Why?

Plot before Stirling's approximation

enter image description here

Mathematica Code:

DiscretePlot[ Exp[Log[(2 S)!] - Log[(S - nE)!] - Log[(S + nE)!] - S Log[4]] /. {S -> 100}, {nE, -9, 9}]

Plot after Stirling's approximation

enter image description here

Mathematica Code:

DiscretePlot[Exp[2 S Log[2S] - (S - nE) Log[S - nE] - (S + nE) Log[S + nE] - S Log[4]] /. {S -> 100}, {nE, -9, 9}]

EDIT 1: Updated Graph 2 to corrected algebra and included higher order Stirling approximation: EDIT 2: Fixed @Henry's plot by changing sign of $\ln\left[\pi\right]$ term.

More Accurate Stirling Approximation suggested by @Henry Higher Order Stirling Approximation suggested by @Henry

DiscretePlot[Exp[(2 S + 1/2) Log[S] - (S - nE + 1/2) Log[S - nE] - (S + nE + 1/2) Log[S + nE] - 1/2 Log[\[Pi]] /. {S -> 100}, {nE, -9, 9}]
2

There are 2 best solutions below

3
On BEST ANSWER

You seem to have written a partly cancelled Exp[2 S Log[S] - ... - S Log[4]] rather than an uncancelled version something like Exp[2 S Log[2 S] - ... - S Log[4]] or a cancelled version like Exp[2 S Log[S] - ... ]. But even that will be a poor approximation.

You could benefit from a more accurate version of Stirling's approximation such as $$\ln( x!) \approx x\ln( x) - x + \tfrac12\ln(2\pi x)$$

which I think would make your calculation

$$Pr(n_E) =\frac{1}{4^S}\frac{(2 S)!}{(S-n_E)! (S +n_E)!} \\\approx \exp\left[ (2S+\tfrac12)\ln(S)-(S-n_E+\tfrac12)\ln(S-n_E)-(S+n_E+\tfrac12)\ln(S+n_E) -\tfrac12 \ln\left(\pi\right) \right] $$

1
On

Stirling's Approximation gives $$ \log(x!)\sim x\log(x)-x+\frac12\log(2\pi x)\color{#CCC}{+\frac1{12x}-\frac1{360x^3}+\frac1{1260x^5}-\dots}\tag1 $$ Applying the main (dark) part of $(1)$ gives $$ \begin{align} \log\left(\frac1{4^S}\frac{(2S)!}{(S+n)!(S-n)!}\right) &\sim-\frac12\log(\pi)+\left(\frac12+2S\right)\log(S)\\ &\phantom{\,\sim\,}-\left(S-n+\frac12\right)\log(S-n)\\ &\phantom{\,\sim\,}-\left(S+n+\frac12\right)\log(S+n)\tag2 \end{align} $$ Approximating $\log(S+n)=\log(S)+\frac nS-\frac{n^2}{2S^2}$ and $\log(S-n)=\log(S)-\frac nS-\frac{n^2}{2S^2}$ in $(2)$ gives $$ \begin{align} \log\left(\frac1{4^S}\frac{(2S)!}{(S+n)!(S-n)!}\right) &\sim-\frac12\log(\pi S)+\left(\frac1{2S^2}-\frac1S\right)n^2\tag3\\ &\sim-\frac12\log(\pi S)-\frac{n^2}S\tag4 \end{align} $$ $(4)$ is the asymptotic approximation of $(3)$ where $\frac1{2S^2}-\frac1S$ is replaced by $-\frac1S$.

Therefore, $$ \frac1{4^S}\frac{(2S)!}{(S+n)!(S-n)!}\sim\frac1{\sqrt{\pi S}}e^{-n^2/S}\tag5 $$ Plotting DiscretePlot[1/Sqrt[Pi S]Exp[-n^2/S]/.S->100,{n,-9,9}] gives

enter image description here