Hypergeometric distribution differential entropy.
The differential entropy for a hypergeometric random variable is given by
where N is the population size, K is the subpopulation size, and n is the number of draws.
var entropy = require( '@stdlib/stats/base/dists/hypergeometric/entropy' );Returns the differential entropy for a hypergeometric distribution with population size N, subpopulation size K, and number of draws n (in nats).
var y = entropy( 16, 11, 4 );
// returns ~1.22
y = entropy( 2, 1, 1 );
// returns ~0.693If provided NaN as any argument, the function returns NaN.
var y = entropy( NaN, 10, 4 );
// returns NaN
y = entropy( 20, NaN, 4 );
// returns NaN
y = entropy( 20, 10, NaN );
// returns NaNIf provided a population size N, subpopulation size K or draws n which is not a nonnegative integer, the function returns NaN.
var y = entropy( 10.5, 4, 2 );
// returns NaN
y = entropy( 10, 1.5, 2 );
// returns NaN
y = entropy( 10, 5, -2.0 );
// returns NaNIf the number of draws n or subpopulation size K exceeds population size N, the function returns NaN.
var y = entropy( 10, 11, 4 );
// returns NaN
y = entropy( 10, 5, 12 );
// returns NaNvar randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var entropy = require( '@stdlib/stats/base/dists/hypergeometric/entropy' );
var i;
var N;
var K;
var n;
var y;
for ( i = 0; i < 10; i++ ) {
N = round( randu() * 20.0 );
K = round( randu() * N );
n = round( randu() * N );
y = entropy( N, K, n );
console.log( 'N: %d, K: %d, n: %d, H(X;N,K,n): %d', N, K, n, y.toFixed( 4 ) );
}