beta, betainc, betaln

Purpose

Beta function.

Synopsis

y = beta(z,w)
y = betainc(x,a,b)
y = betaln(z,w)

Description

y = beta(z,w) is the beta function

or equivalently gamma(z)*gamma(w)./gamma(z+w). If both z and w are vectors or matrices, they must be the same size.

y = betainc(x,z,w) is the incomplete beta function

y = betaln(z,w) is the natural logarithm of the beta function, log(beta(z,w)), computed without computing beta(z,w). Since the beta function can range over very large or very small values, its logarithm is sometimes more useful. If both z and w are vectors or matrices, they must be the same size.

Examples

format rat 
beta((0:10)',3)
          
ans =
     1/0 
     1/3 
     1/12 
     1/30 
     1/60 
     1/105 
     1/168 
     1/252 
     1/360 
     1/495 
     1/660 
In this case, with integer arguments,

beta(n,3)
= (n-1)!*2!/(n+2)!
= 2/(n*(n+1)*(n+2))
is the ratio of fairly small integers and the rational format is able to recover the exact result.

For x = 510, betaln(x,x) = -708.8616, which, on a computer with IEEE arithmetic, is slightly less than log(realmin). Here beta(x,x) would underflow (or be denormal).

Algorithm

beta(z,w) = exp(gammaln(z)+gammaln(w)-gammaln(z+w))
betaln(z,w) = gammaln(z)+gammaln(w)-gammaln(z+w)

(c) Copyright 1994 by The MathWorks, Inc.