Learn R Programming

DPQ (version 0.5-9)

lfastchoose: R versions of Simple Formulas for Logarithmic Binomial Coefficients

Description

Provide R versions of simple formulas for computing the logarithm of (the absolute value of) binomial coefficients, i.e., simpler, more direct formulas than what (the C level) code of R's lchoose() computes.

Usage

lfastchoose(n, k)
 f05lchoose(n, k)

Value

a numeric vector with the same attributes as n + k.

Arguments

n

a numeric vector.

k

a integer valued numeric vector.

Author

Martin Maechler

See Also

Examples

Run this code
lfastchoose # function(n, k) lgamma(n + 1) - lgamma(k + 1) - lgamma(n - k + 1)
f05lchoose  # function(n, k) lfastchoose(n = floor(n + 0.5), k = floor(k + 0.5))

## interesting cases ?

Run the code above in your browser using DataLab