R: (Log) Beta Approximations

lbeta {DPQ} | R Documentation

## (Log) Beta Approximations

### Description

Compute `log(beta(a,b))` in a simple (fast) or asymptotic way.

### Usage

    lbetaM   (a, b, k.max = 5, give.all = FALSE)
    lbeta_asy(a, b, k.max = 5, give.all = FALSE)
    lbetaMM  (a, b, cutAsy = 1e-2, verbose = FALSE)

     betaI(a, n)
    lbetaI(a, n)

    logQab_asy(a, b, k.max = 5, give.all = FALSE)
    Qab_terms(a, k)

### Arguments

`a, b, n` | the Beta parameters, see `beta`; `n` must be a positive integer and “small”.
`k.max` | ..
`give.all` | `logical` ..
`cutAsy` | cutoff value from where to switch to asymptotic formula.

`verbose` | logical (or integer) indicating if and how much monitoring information should be printed to the console.
`k` | the number of terms in the series expansion of `Qab_terms()`, currently must be in \{0, 1, .., 5\}.

### Details

All `lbeta*()` functions compute `log(beta(a,b))`.

We use Qab = Qab(a,b) for

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

which is numerically challenging when b becomes large compared to `a`, or a << b.

With the beta function

B(a,b) = Γ(a)Γ(b)/Γ(a+b) = Γ(a) / Qab,

and hence

log B(a,b) = logΓ(a) + logΓ(b) - logΓ(a+b) = logΓ(a) - log Qab,

or in R, `lBeta(a,b) := lgamma(a) - logQab(a,b)`.

Indeed, typically everything has to be computed in log scale, as both Γ(b) and Γ(a+b) would overflow numerically for large b. Consequently, we use `logQab*()`, and for the large b case `logQab_asy()` specifically,

\code{logQab(a,b)} := \log( Qab(a,b) ).

Note this is related to trying to get asymptotic formula for Γ ratios, notably formula (6.1.47) in Abramowitz and Stegun.

Note how this is related to computing `qbeta()` in boundary cases, and see `algdiv()` ‘Details’ about this.

We also have a vignette about this, but really the problem has been adressed pragmatically by the authors of TOMS 708, see the ‘References’ in `pbeta`, by their routine `algdiv()` which also is available in our package DPQ.

### Value

a fast or simple (approximate) computation of `lbeta(a,b)`.

### Author(s)

Martin Maechler

### References

Abramowitz, M. and Stegun, I. A. (1972) Handbook of Mathematical Functions. New York: Dover. https://en.wikipedia.org/wiki/Abramowitz_and_Stegun provides links to the full text which is in public domain.

Formula (6.1.47), p.257

### See Also

R's `beta` function; `algdiv()`.

### Examples

      ## TODO

[Package DPQ version 0.4-4 Index]