Skip to content

Latest commit

 

History

History
142 lines (91 loc) · 3.16 KB

File metadata and controls

142 lines (91 loc) · 3.16 KB

Entropy

Hypergeometric distribution entropy.

The entropy (in nats) for a hypergeometric random variable is

Entropy for a hypergeometric distribution.

where N is the population size, K is the subpopulation size, and n is the number of draws.

Usage

var entropy = require( '@stdlib/stats/base/dists/hypergeometric/entropy' );

entropy( N, K, n )

Returns the entropy of a hypergeometric distribution with parameters N (population size), K (subpopulation size), and n (number of draws).

var v = entropy( 16, 11, 4 );
// returns ~1.216

v = entropy( 2, 1, 1 );
// returns ~0.693

If provided NaN for any parameter, the function returns NaN.

var v = entropy( NaN, 10, 4 );
// returns NaN

v = entropy( 20, NaN, 4 );
// returns NaN

v = entropy( 20, 10, NaN );
// returns NaN

If provided a parameter that is not a nonnegative integer, the function returns NaN.

var v = entropy( 10.5, 5, 2 );
// returns NaN

v = entropy( 10, 1.5, 2 );
// returns NaN

v = entropy( 10, 5, -2.0 );
// returns NaN

If the number of draws n exceeds the population size N, the function returns NaN.

var v = entropy( 10, 5, 12 );
// returns NaN

If the subpopulation size K exceeds the population size N, the function returns NaN.

var v = entropy( 10, 12, 5 );
// returns NaN

Examples

var entropy = require( '@stdlib/stats/base/dists/hypergeometric/entropy' );

var v = entropy( 16, 11, 4 );
console.log( v );
// => 1.2156868611027067

v = entropy( 2, 1, 1 );
console.log( v );
// => 0.6931471805599453

v = entropy( 10, 5, 12 );
console.log( v );
// => NaN