Binomial coefficient. Equivalent to R's choose(). Takes single numbers.
n may be any real number. k is rounded to the nearest integer (as R does, which also warns
when k is not close to an integer); choose(n, k) is 0 for k < 0 and 1 for k = 0.
For integer n the result is an integer (exact up to 2^53).
Edge cases where R differs from the mathematical value, followed by default (rCompatible: false
returns the mathematical value instead):
n within 1e-9 max(1, |n|) of an integer is treated as that integer, so choose(1e-10, 2) is 0
(mathematically -5e-11); for n < 0 and k >= 30 the tolerance is relative to k - 1 - n;
choose(n, Infinity) is 0 for n >= 0 (otherwise NaN);
choose(±Infinity, k) is NaN for k >= 30 (±Infinity below).
Binomial coefficient. Equivalent to R's
choose(). Takes single numbers.nmay be any real number.kis rounded to the nearest integer (as R does, which also warns whenkis not close to an integer);choose(n, k)is 0 fork < 0and 1 fork = 0. For integernthe result is an integer (exact up to 2^53).Edge cases where R differs from the mathematical value, followed by default (
rCompatible: falsereturns the mathematical value instead):nwithin 1e-9 max(1, |n|) of an integer is treated as that integer, sochoose(1e-10, 2)is 0 (mathematically -5e-11); forn < 0andk >= 30the tolerance is relative tok - 1 - n;choose(n, Infinity)is 0 forn >= 0(otherwiseNaN);choose(±Infinity, k)isNaNfork >= 30(±Infinitybelow).