Efficient and accurate approximatiion of logarithm of binomial coefficients

323 Views Asked by At

I am searching for an efficient and accurate way to approximate the logarithm of binomial coefficients since I have to deal with extremely large numbers in C++. Using Stirling approximation, I am able to compute values very fast:

$ln\binom{n}{k} \approx n\cdot ln(n) - m\cdot ln(k) - (n-k)\cdot ln(n-k) + \frac{1}{2}\cdot (ln(n) - ln(k) - ln(n-k) - ln(2\pi))$

However, the approximation is not very accurate. Since I am not very strong in numerical analysis, I would like to know if there is a better way to approximate $ln\binom{n}{k}$.

Any help would be much appreciated.

1

There are 1 best solutions below

1
On BEST ANSWER

$$\binom{n}{k}=\frac{n!}{(n-k)! \, k!}=\frac{\Gamma(n+1)}{\Gamma(n-k+1)\,\Gamma(k+1)}$$ $$\log (\binom{n}{k})=\log(\Gamma(n+1))-\log(\Gamma(n-k+1))-\log(\Gamma(k+1))$$

Now, have a look here.