Logarithm of Binomial Coefficient
Compute the natural logarithm of the binomial coefficient.
Installation
npm install @stdlib/math-base-special-binomcoefln
Usage
var binomcoefln = require( '@stdlib/math-base-special-binomcoefln' );
binomcoefln( n, k )
Evaluates the binomial coefficient of two integers n
and k
.
var v = binomcoefln( 8, 2 );
v = binomcoefln( 0, 0 );
v = binomcoefln( -4, 2 );
v = binomcoefln( 88, 3 );
v = binomcoefln( NaN, 3 );
v = binomcoefln( 5, NaN );
v = binomcoefln( NaN, NaN );
For negative k
, the function returns -Infinity
.
var v = binomcoefln( 2, -1 );
v = binomcoefln( -3, -1 );
The function returns NaN
for non-integer n
or k
.
var v = binomcoefln( 2, 1.5 );
v = binomcoefln( 5.5, 2 );
Examples
var randu = require( '@stdlib/random-base-randu' );
var round = require( '@stdlib/math-base-special-round' );
var binomcoefln = require( '@stdlib/math-base-special-binomcoefln' );
var n;
var k;
var i;
for ( i = 0; i < 100; i++ ) {
n = round( (randu()*40.0) - 10.0 );
k = round( randu()*20.0 );
console.log( 'ln( %d choose %d ) = %d', n, k, binomcoefln( n, k ) );
}
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
License
See LICENSE.
Copyright
Copyright © 2016-2021. The Stdlib Authors.
0.0.2 (2021-06-16)
No changes reported for this release.
</section>
<!-- /.release -->
<section class="release" id="v0.0.1">