# the incredible accuracy of Stirling’s approximation

December 6, 2016
By

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The last riddle from the Riddler [last before The Election] summed up to find the probability of a Binomial B(2N,½) draw ending up at the very middle, N. Which is

$\wp={2N \choose N}2^{-2N}$

If one uses the standard Stirling approximation to the factorial function,

log(N!)≈Nlog(N) – N + ½log(2πN)

the approximation to ℘ is 1/√πN, which is not perfect for the small values of N. Introducing the second order Stirling approximation,

log(N!)≈Nlog(N) – N + ½log(2πN) + 1/12N

the approximation become

℘≈exp(-1/8N)/√πN

which fits almost exactly from the start. This accuracy was already pointed out by William Feller, Section II.9.

Filed under: Kids, R, Statistics Tagged: American elections 2016, Stirling approximation, The Riddler

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.