I need to calculate $\text{B}_x(a,b)$ on the cheap, without too many coefficients and loops. For the complete $\text{B}(a,b)$, I can use $\Gamma(a)\Gamma(b)/\Gamma(a+b)$, and Stirling's approximation for $\Gamma(.)$. Is there a way to calculate the incomplete beta function using Stirling's approximation?
Easy approximation of the incomplete beta function $\text{B}_x(a,b)$
-
1FWIW: due to the properties of ${}_2 F_1$, incomplete beta satisfies three term recurrence relations, which might be helpful if you'll be fixing some parameters. If for instance your goal is to numerically compute the CDF for the $\mathbf F$ or Student $t$ distributions, there are specially adapted methods for that as well. – 2011-07-27
2 Answers
You can express ${\rm B}(x;a,b)$ in terms of the hypergeometric function
$ F(a,b;c;z) = 1 + \frac{{ab}}{c}z + \frac{{a(a + 1)b(b + 1)}}{{c(c + 1)2!}}z^2 + \cdots , $ as $ {\rm B}(x;a,b) = \frac{{x^a }}{a}F(a,1 - b;a + 1;x) $ or $ {\rm B}(x;a,b) = \frac{{x^a (1 - x)^b }}{a}F(a + b,1;a + 1;x). $ For this and more, see here.
I believe that one of the fastest ways to compute $\text{B}(a,b,x)$ is to simply use numerical integration. The integrand is very nice, and the interval is small. In fact, I think given a fixed amount of time, numerical integration will yield higher accuracy for $\text{B}(a,b)$ then Stirlings formula.
There are many times where we have explicit formulas for certain integrals in terms of the gamma function and other well known functions, but to evaluate those integrals the basic numerical integration is used instead of evaluating the known exact expression.