Home  /  Resources & support  /  FAQs  /  Calculating the beta function

How do I calculate values of the beta function?

Title   Calculating the beta function
Author Nicholas J. Cox, Durham University, UK

The beta function can be defined in terms of the gamma function and thus, calculated using the Stata functions exp() and lngamma(). On the latter, see the section "Mathematical functions" of the [FN] Stata Functions Reference Manual. Given positive arguments a and b, the beta function

        Β(a,b) = Γ(a) Γ(b) / Γ(a + b)

can be calculated from


        exp(lngamma(a) + lngamma(b) - lngamma(a + b))  

In this expression, each argument may be a number, a variable, or, more generally, itself an expression.