Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
To give a genuinely useful answer, you need to specify the specific ranges of $a$, $b$, and $x$ you are interested in. Methods that, for instance, work nicely for "human-sized" $a$ and $b$ (e.g. Eric's suggestion) fail spectacularly when either of $a$ or $b$ is large. If $x$ is outside $[0,1]$, special methods are needed, too... – J. M. Jul 27 '11 at 2:11
FWIW: 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. – J. M. Jul 27 '11 at 2:14

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.

share|cite|improve this answer

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.