And trust us, this is gonna blow your mind!
So what exactly is the gamma function? Well, it’s basically just a mathematical tool for calculating factorials. You know, like in math class when you multiply all those numbers together to find out how many possible ways there are to arrange a set of objects (like if you have 5 red balls and 3 blue ones, how many different combinations can you make?).
But instead of actually doing the multiplication every time we need it, we can use this gamma function thingy. And here’s where Stirling comes in he figured out a way to approximate (or guess) what the answer should be based on some fancy math formulas.
So let’s say you want to find out how many possible ways there are to arrange 10 red balls and 5 blue ones. Well, using our trusty gamma function, we can calculate that:
factorial(10 + 5) = (10 * 9 * 8 * … * 2 * 1) * (5 * 4 * 3 * … * 2 * 1)
But instead of actually doing all those multiplications, we can use Stirling’s approximation to estimate what the answer should be. And here’s where things get really cool!
According to Stirling’s formula (which is basically just a fancy way of saying “guess”), if you have a really big number like 10^5 or something, then:
ln(factorial(n)) = n * ln(n) n + some other stuff that we don’t care about right now
So for our example with the red and blue balls, we can use this formula to estimate how many possible ways there are. And here’s where things get really fun!
ln(factorial(10+5)) = (10 + 5) * ln(10+5) (10+5) + some other stuff that we don’t care about right now
And if you plug in those numbers, you get:
ln(factorial(15)) = 15 * ln(15.46…) 15.46… + some other stuff that we don’t care about right now
Using Stirling’s approximation for the gamma function, we can estimate how many possible ways there are to arrange a set of objects without actually doing all those multiplications (which would take forever). And best of all, this formula works really well even when your numbers get really big or really small.
So next time you need to calculate a factorial in math class, just remember: Stirling’s approximation for the gamma function is your new BFF!