rStats.js v1.3.0
    Preparing search index...

    Function lchoose

    • Logarithm of the absolute value of the binomial coefficient. Equivalent to R's lchoose(). Takes single numbers: log(abs(choose(n, k))), computed without overflow.

      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 (for k >= 2; for n < 0 the tolerance is relative to k - 1 - n); lchoose(n, Infinity) is -Infinity for n >= 0 (otherwise NaN); lchoose(±Infinity, k) is NaN for k >= 2 (Infinity for k = 1).

      Parameters

      • n: number

        Number of items (any real number).

      • k: number

        Number chosen (rounded to an integer).

      • Optionaloptions: RCompatibleOptions

        rCompatible (default true).

      Returns number

      log|choose(n, k)| (-Infinity where choose(n, k) is 0).

      lchoose(1000, 500);  // 689.4672615678512