lbeta
Beta Function and its Logarithm
Description
Calculates the beta function or its logarithm.
Usage
beta(a, b)
lbeta(a, b)
Arguments
a |
A numeric vector. The values should be non-negative.
|
b |
A numeric vector. The values should be non-negative.
|
Details
beta(a,b) can be defined mathematically as gamma(a)*gamma(b)/gamma(a+b).
This version is defined only for non-negative real a and b.
For large a and b, the mathematically correct value of beta(a,b)
will be smaller than the smallest positive floating point number so this approximation
will return 0. Use lbeta(a,b) to avoid this underflow problem.
beta(a,b) is computed using the Boost library.
lbeta(a,b) is computed using Fullerton's (1977) code from http://netlib.org/fn.
Value
beta(a,b) returns an approximation to the beta function and
lbeta(a,b) returns an approximation to its natural logarithm.
They both return NaN for negative arguments and give an error
if an argument is complex.
See Also
See
Beta for functions related to the beta distribution.
gamma and
lgamma compute the gamma function
and its logarithm.
Examples
beta(10, 3) # 2/(10*(10+1)*(10+2))
lbeta(10, 3) # its logarithm
beta(1000, c(999, 1000)) # underflows to 0
lbeta(1000, c(999, 1000)) # large negative logarithms