Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

6.3 Factorial Approximations

Many probability calculations involve factorials. As discussed in Section 6.2, factorials are often hard to work with. This section introduces a method for approximating factorials using simpler functions. These approximations make it easier to answer questions like, “how big is n!n!?”, or "how big is n choose kn \text{ choose } k?", when nn and kk are large.

Consider the definition of the factorial:

n!=n×(n1)×(n2)× ... ×2×1.n! = n \times (n - 1) \times (n - 2 ) \times \text{ ... } \times 2 \times 1.

This product involves nn terms. The early terms all are of size nn. So, to a very rough approximation, n!nnn! \approx n^n. Clearly n!<nnn! < n^n since all of the terms in the product except the first are less than nn. Half are larger than n/2n/2 and half are smaller, so a better approximation is (n/2)n(n/2)^n. Stirling’s approximation provides an accurate estimate for n!n! using a function roughly of the form (n/e)n(n/e)^n.

Stirling’s approximation is remarkably accurate, even for relatively small nn. Here’s a table comparing values. The values for the approximation have been rounded to the tenth’s place.

nn1234567
n!n!126241207205,0405,040
Stirling0.91.95.85.8 23.5118.0118.0 710.14,980.44,980.4

Notice that, while the absolute error in the approximation grows as nn increases, the relative error is vanishing. The table below provides the errors, printed to their first significant figure.

nn1234567
Abs. Error: n!2πe(n/e)1/2\mid n! - \sqrt{2 \pi e} (n/e)^{1/2} \mid 0.080.080.20.52.01060
Rel. Error: n!2πe(n/e)1/2n!\frac{\mid n! - \sqrt{2 \pi e} (n/e)^{1/2} \mid}{n!}0.080.040.030.020.020.010.01

Stirling’s approximation has less than a 2% error for n5n \geq 5, and less than a 1% error for n9n \geq 9.