Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.math.internal.log_binomial

License:
Authors:
John Michael Hall
T logFactorial(T = double)(ulong count, ulong start = 1)
if (isFloatingPoint!T);
Examples:
import mir.math.common: approxEqual, log;
assert(logFactorial(0) == 0);
assert(logFactorial(1) == 0);
assert(logFactorial(2).approxEqual(log(1.0 * 2)));
assert(logFactorial(3).approxEqual(log(1.0 * 2 * 3)));
assert(logFactorial(4).approxEqual(log(1.0 * 2 * 3 * 4)));
assert(logFactorial(5).approxEqual(log(1.0 * 2 * 3 * 4 * 5)));
T logBinomialCoefficient(T = double)(ulong n, uint k)
if (isFloatingPoint!T);
Examples:
import mir.bignum.fp: Fp, fp_log;
import mir.math.numeric: binomialCoefficient;
import mir.math.common: approxEqual, log;

assert(logBinomialCoefficient(5, 1).approxEqual(log(5.0)));
assert(logBinomialCoefficient(5, 2).approxEqual(fp_log!double(binomialCoefficient(5, 2))));
assert(logBinomialCoefficient(5, 3).approxEqual(fp_log!double(binomialCoefficient(5, 3))));
assert(logBinomialCoefficient(5, 4).approxEqual(fp_log!double(binomialCoefficient(5, 4))));