diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/README.md b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/README.md new file mode 100644 index 000000000000..1c40466e8589 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/README.md @@ -0,0 +1,172 @@ + + +# Entropy + +> [Hypergeometric][hypergeometric-distribution] distribution [differential entropy][entropy]. + + + +
+ +The [differential entropy][entropy] for a [hypergeometric][hypergeometric-distribution] random variable is given by + + + +```math +H(X) = - \sum_{k=\max(0, n+K-N)}^{\min(n, K)} P(X=k) \ln(P(X=k)) +``` + + + + + +where `N` is the population size, `K` is the subpopulation size, and `n` is the number of draws. + +
+ + + + + +
+ +## Usage + +```javascript +var entropy = require( '@stdlib/stats/base/dists/hypergeometric/entropy' ); +``` + +#### entropy( N, K, n ) + +Returns the [differential entropy][entropy] for a [hypergeometric][hypergeometric-distribution] distribution with population size `N`, subpopulation size `K`, and number of draws `n` (in [nats][nats]). + +```javascript +var y = entropy( 16, 11, 4 ); +// returns ~1.22 + +y = entropy( 2, 1, 1 ); +// returns ~0.693 +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = entropy( NaN, 10, 4 ); +// returns NaN + +y = entropy( 20, NaN, 4 ); +// returns NaN + +y = entropy( 20, 10, NaN ); +// returns NaN +``` + +If provided a population size `N`, subpopulation size `K` or draws `n` which is not a nonnegative integer, the function returns `NaN`. + +```javascript +var y = entropy( 10.5, 4, 2 ); +// returns NaN + +y = entropy( 10, 1.5, 2 ); +// returns NaN + +y = entropy( 10, 5, -2.0 ); +// returns NaN +``` + +If the number of draws `n` or subpopulation size `K` exceeds population size `N`, the function returns `NaN`. + +```javascript +var y = entropy( 10, 11, 4 ); +// returns NaN + +y = entropy( 10, 5, 12 ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var 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 ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/benchmark/benchmark.js new file mode 100644 index 000000000000..ea5103f0b83e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/benchmark/benchmark.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var entropy = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var len; + var N; + var K; + var n; + var y; + var i; + + len = 100; + N = new Float64Array( len ); + K = new Float64Array( len ); + n = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + N[ i ] = discreteUniform( 1, 100 ); + K[ i ] = discreteUniform( 1, N[ i ] ); + n[ i ] = discreteUniform( 1, N[ i ] ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = entropy( N[ i % len ], K[ i % len ], n[ i % len ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/repl.txt new file mode 100644 index 000000000000..59bf95e10a58 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/repl.txt @@ -0,0 +1,54 @@ + +{{alias}}( N, K, n ) + Returns the differential entropy of a hypergeometric distribution. + + If provided `NaN` as any argument, the function returns `NaN`. + + If provided a population size `N`, subpopulation size `K` or draws `n` which + is not a nonnegative integer, the function returns `NaN`. + + If the number of draws `n` or the subpopulation size `K` exceed population + size `N`, the function returns `NaN`. + + Parameters + ---------- + N: integer + Population size. + + K: integer + Subpopulation size. + + n: integer + Number of draws. + + Returns + ------- + out: number + Entropy. + + Examples + -------- + > var v = {{alias}}( 16, 11, 4 ) + ~1.22 + > v = {{alias}}( 2, 1, 1 ) + ~0.693 + + > v = {{alias}}( 10, 5, 12 ) + NaN + > v = {{alias}}( 10.3, 10, 4 ) + NaN + > v = {{alias}}( 10, 5.5, 4 ) + NaN + > v = {{alias}}( 10, 5, 4.5 ) + NaN + + > v = {{alias}}( NaN, 10, 4 ) + NaN + > v = {{alias}}( 20, NaN, 4 ) + NaN + > v = {{alias}}( 20, 10, NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/types/index.d.ts new file mode 100644 index 000000000000..cd9c238352cd --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/types/index.d.ts @@ -0,0 +1,75 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the differential entropy of a hypergeometric distribution. +* +* ## Notes +* +* - If provided a population size `N`, subpopulation size `K` or draws `n` which is not a nonnegative integer, the function returns `NaN`. +* - If the number of draws `n` or subpopulation size `K` exceed population size `N`, the function returns `NaN`. +* +* @param N - population size +* @param K - subpopulation size +* @param n - number of draws +* @returns entropy +* +* @example +* var v = entropy( 16, 11, 4 ); +* // returns ~1.22 +* +* @example +* var v = entropy( 2, 1, 1 ); +* // returns ~0.693 +* +* @example +* var v = entropy( 10, 5, 12 ); +* // returns NaN +* +* @example +* var v = entropy( 10.3, 10, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 10, 5.5, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 10, 5, 4.5 ); +* // returns NaN +* +* @example +* var v = entropy( NaN, 10, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 20, NaN, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 20, 10, NaN ); +* // returns NaN +*/ +declare function entropy( N: number, K: number, n: number ): number; + + +// EXPORTS // + +export = entropy; diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/types/test.ts new file mode 100644 index 000000000000..9c265239ab1a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/docs/types/test.ts @@ -0,0 +1,58 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import entropy = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + entropy( 16, 11, 4 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than numbers... +{ + entropy( true, 11, 4 ); // $ExpectError + entropy( false, 11, 4 ); // $ExpectError + entropy( '5', 11, 4 ); // $ExpectError + entropy( [], 11, 4 ); // $ExpectError + entropy( {}, 11, 4 ); // $ExpectError + entropy( ( x: number ): number => x, 11, 4 ); // $ExpectError + + entropy( 16, true, 4 ); // $ExpectError + entropy( 16, false, 4 ); // $ExpectError + entropy( 16, '5', 4 ); // $ExpectError + entropy( 16, [], 4 ); // $ExpectError + entropy( 16, {}, 4 ); // $ExpectError + entropy( 16, ( x: number ): number => x, 4 ); // $ExpectError + + entropy( 16, 11, true ); // $ExpectError + entropy( 16, 11, false ); // $ExpectError + entropy( 16, 11, '5' ); // $ExpectError + entropy( 16, 11, [] ); // $ExpectError + entropy( 16, 11, {} ); // $ExpectError + entropy( 16, 11, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + entropy(); // $ExpectError + entropy( 16 ); // $ExpectError + entropy( 16, 11 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/examples/index.js new file mode 100644 index 000000000000..043d0a355814 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var entropy = require( './../lib' ); + +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 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/lib/index.js new file mode 100644 index 000000000000..342c112a5c3c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Hypergeometric distribution differential entropy. +* +* @module @stdlib/stats/base/dists/hypergeometric/entropy +* +* @example +* var entropy = require( '@stdlib/stats/base/dists/hypergeometric/entropy' ); +* +* var v = entropy( 16, 11, 4 ); +* // returns ~1.22 +* +* v = entropy( 2, 1, 1 ); +* // returns ~0.693 +*/ + +// MODULES // + +var entropy = require( './main.js' ); + + +// EXPORTS // + +module.exports = entropy; diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/lib/main.js new file mode 100644 index 000000000000..b025355f795b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/lib/main.js @@ -0,0 +1,117 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var incrsum = require( '@stdlib/stats/incr/sum' ); +var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var pmf = require( '@stdlib/stats/base/dists/hypergeometric/pmf' ); + + +// MAIN // + +/** +* Returns the differential entropy of a hypergeometric distribution. +* +* @param {NonNegativeInteger} N - population size +* @param {NonNegativeInteger} K - subpopulation size +* @param {NonNegativeInteger} n - number of draws +* @returns {NonNegativeNumber} entropy +* +* @example +* var v = entropy( 16, 11, 4 ); +* // returns ~1.22 +* +* @example +* var v = entropy( 2, 1, 1 ); +* // returns ~0.693 +* +* @example +* var v = entropy( 10, 5, 12 ); +* // returns NaN +* +* @example +* var v = entropy( 10.3, 10, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 10, 5.5, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 10, 5, 4.5 ); +* // returns NaN +* +* @example +* var v = entropy( NaN, 10, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 20, NaN, 4 ); +* // returns NaN +* +* @example +* var v = entropy( 20, 10, NaN ); +* // returns NaN +*/ +function entropy( N, K, n ) { + var min; + var max; + var acc; + var p; + var i; + + if ( + isnan( N ) || + isnan( K ) || + isnan( n ) + ) { + return NaN; + } + if ( + !isNonNegativeInteger( N ) || + !isNonNegativeInteger( K ) || + !isNonNegativeInteger( n ) || + N === PINF || + K === PINF || + K > N || + n > N + ) { + return NaN; + } + min = ( n + K - N > 0 ) ? n + K - N : 0; + max = ( n < K ) ? n : K; + acc = incrsum(); + for ( i = min; i <= max; i++ ) { + p = pmf( i, N, K, n ); + if ( p > 0 ) { + acc( -p * ln( p ) ); + } + } + return acc(); +} + + +// EXPORTS // + +module.exports = entropy; diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/package.json b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/package.json new file mode 100644 index 000000000000..f65590aad634 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/stats/base/dists/hypergeometric/entropy", + "version": "0.0.0", + "description": "Hypergeometric distribution differential entropy.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": false, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": { + "@stdlib/math/base/assert/is-nan": "^0.2.2", + "@stdlib/math/base/assert/is-nonnegative-integer": "^0.2.2", + "@stdlib/math/base/special/ln": "^0.2.2", + "@stdlib/constants/float64/pinf": "^0.2.2", + "@stdlib/stats/base/dists/hypergeometric/pmf": "^0.2.2", + "@stdlib/stats/incr/sum": "^0.2.2" + }, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "distribution", + "dist", + "entropy", + "discrete", + "hypergeometric", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/test/test.js new file mode 100644 index 000000000000..924fcd927027 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/entropy/test/test.js @@ -0,0 +1,140 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var entropy = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof entropy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { + var v = entropy( NaN, 10, 4 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = entropy( 20, NaN, 4 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = entropy( 20, 10, NaN ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` which is not a nonnegative integer, the function returns `NaN`', function test( t ) { + var v; + + v = entropy( 10.5, 4, 2 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = entropy( -2, 4, 2 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = entropy( PINF, 10, 5 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `K` which is not a nonnegative integer, the function returns `NaN`', function test( t ) { + var y; + + y = entropy( 20, 3.5, 10 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = entropy( 20, -2, 10 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = entropy( 20, PINF, 10 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `n` which is not a nonnegative integer, the function returns `NaN`', function test( t ) { + var y; + + y = entropy( 40, 20, 3.5 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = entropy( 40, 20, -2 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = entropy( 40, 20, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided parameters such that `K > N` or `n > N`, the function returns `NaN`', function test( t ) { + var y; + + y = entropy( 10, 11, 5 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = entropy( 10, 5, 11 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the entropy (N=2, K=1, n=1)', function test( t ) { + var expected; + var delta; + var tol; + var v; + + v = entropy( 2, 1, 1 ); + expected = ln( 2.0 ); + delta = abs( v - expected ); + tol = 1.0 * EPS * abs( expected ); + + t.ok( delta <= tol, 'within tolerance. v: '+v+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.end(); +}); + +tape( 'the function returns the entropy (N=4, K=2, n=2)', function test( t ) { + var expected; + var delta; + var tol; + var v; + + v = entropy( 4, 2, 2 ); + + // -1/3 ln 2 + ln 3 + expected = ( -1.0/3.0 * ln(2.0) ) + ln(3.0); + delta = abs( v - expected ); + tol = 4.0 * EPS * abs( expected ); + + t.ok( delta <= tol, 'within tolerance. v: '+v+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/lib/index.js index d10859c4ac35..1ab908858506 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/lib/index.js @@ -54,6 +54,15 @@ setReadOnly( hypergeometric, 'cdf', require( '@stdlib/stats/base/dists/hypergeom */ setReadOnly( hypergeometric, 'Hypergeometric', require( '@stdlib/stats/base/dists/hypergeometric/ctor' ) ); +/** +* @name entropy +* @memberof hypergeometric +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/hypergeometric/entropy} +*/ +setReadOnly( hypergeometric, 'entropy', require( '@stdlib/stats/base/dists/hypergeometric/entropy' ) ); + /** * @name kurtosis * @memberof hypergeometric