The entropy (in nats) for a Poisson random variable is
where λ is the mean parameter.
var entropy = require( '@stdlib/stats/base/dists/poisson/entropy' );Returns the entropy of a Poisson distribution with mean parameter lambda (in nats).
var v = entropy( 9.0 );
// returns ~2.508
v = entropy( 0.5 );
// returns ~0.928If provided lambda < 0, the function returns NaN.
var v = entropy( -1.0 );
// returns NaNvar uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var entropy = require( '@stdlib/stats/base/dists/poisson/entropy' );
var opts = {
'dtype': 'float64'
};
var lambda = uniform( 10, 0.0, 20.0, opts );
logEachMap( 'λ: %0.4f, H(X;λ): %0.4f', lambda, entropy );#include "stdlib/stats/base/dists/poisson/entropy.h"Returns the entropy of a Poisson distribution with mean parameter lambda (in nats).
double out = stdlib_base_dists_poisson_entropy( 9.0 );
// returns ~2.508The function accepts the following arguments:
- lambda:
[in] doublemean parameter.
double stdlib_base_dists_poisson_entropy( const double lambda );#include "stdlib/stats/base/dists/poisson/entropy.h"
#include <stdlib.h>
#include <stdio.h>
static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v*(max-min) );
}
int main( void ) {
double lambda;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
lambda = random_uniform( 0.0, 20.0 );
y = stdlib_base_dists_poisson_entropy( lambda );
printf( "λ: %lf, h(X;λ): %lf\n", lambda, y );
}
}