diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/README.md new file mode 100644 index 000000000000..0d62c5c213a4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/README.md @@ -0,0 +1,137 @@ + + +# Mode + +> Planck (discrete exponential) distribution [mode][mode]. + + + +
+ +The [mode][mode] for a Planck random variable with shape parameter `λ` is + + + +```math +\mathop{\mathrm{mode}}\left( X \right) = 0 +``` + + + +
+ + + + + +
+ +## Usage + +```javascript +var mode = require( '@stdlib/stats/base/dists/planck/mode' ); +``` + +#### mode( lambda ) + +Returns the [mode][mode] of a Planck distribution with shape parameter `lambda`. + +```javascript +var v = mode( 0.1 ); +// returns 0 + +v = mode( 1.5 ); +// returns 0 +``` + +If provided a shape parameter `lambda` is nonpositive or `NaN`, the function returns `NaN`. + +```javascript +var v = mode( NaN ); +// returns NaN + +v = mode( -1.5 ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var mode = require( '@stdlib/stats/base/dists/planck/mode' ); + +var lambda = uniform( 10, 0.1, 5.0 ); + +var v; +var i; +for ( i = 0; i < lambda.length; i++ ) { + v = mode( lambda[ i ] ); + console.log( 'λ: %d, mode(X;λ): %d', lambda[ i ].toFixed( 4 ), v.toFixed( 4 ) ); +} +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/benchmark/benchmark.js new file mode 100644 index 000000000000..8e8500b8b07b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/benchmark/benchmark.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var mode = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var lambda; + var y; + var i; + + lambda = uniform( 100, 0.1, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = mode( lambda[ i % lambda.length ] ); + 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/planck/mode/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/repl.txt new file mode 100644 index 000000000000..b4567e8a667f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/repl.txt @@ -0,0 +1,26 @@ + +{{alias}}( λ ) + Returns the mode of a Planck distribution with shape parameter `λ`. + + If `lambda <= 0`, the function returns `NaN`. + + Parameters + ---------- + λ: number + Shape parameter. + + Returns + ------- + out: integer + Mode. + + Examples + -------- + > var v = {{alias}}( 0.1 ) + 0 + > v = {{alias}}( 1.5 ) + 0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/types/index.d.ts new file mode 100644 index 000000000000..488fb5289de0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/types/index.d.ts @@ -0,0 +1,52 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 mode of a Planck distribution. +* +* ## Notes +* +* - If `lambda <= 0`, the function returns `NaN`. +* +* @param lambda - shape parameter +* @returns mode +* +* @example +* var v = mode( 0.1 ); +* // returns 0 +* +* @example +* var v = mode( 1.5 ); +* // returns 0 +* +* @example +* var v = mode( -1.1 ); +* // returns NaN +* +* @example +* var v = mode( NaN ); +* // returns NaN +*/ +declare function mode( lambda: number ): number; + + +// EXPORTS // + +export = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/types/test.ts new file mode 100644 index 000000000000..a1f70068852e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/docs/types/test.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 mode = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + mode( 0.3 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + mode( true ); // $ExpectError + mode( false ); // $ExpectError + mode( null ); // $ExpectError + mode( undefined ); // $ExpectError + mode( '5' ); // $ExpectError + mode( [] ); // $ExpectError + mode( {} ); // $ExpectError + mode( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + mode(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/examples/index.js new file mode 100644 index 000000000000..987223b2b815 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/examples/index.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var mode = require( './../lib' ); + +var lambda = uniform( 10, 0.1, 5.0 ); + +var v; +var i; +for ( i = 0; i < lambda.length; i++ ) { + v = mode( lambda[ i ] ); + console.log( 'λ: %d, mode(X;λ): %d', lambda[ i ].toFixed( 4 ), v.toFixed( 4 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/lib/index.js new file mode 100644 index 000000000000..06b9e6b178ba --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Planck distribution mode. +* +* @module @stdlib/stats/base/dists/planck/mode +* +* @example +* var mode = require( '@stdlib/stats/base/dists/planck/mode' ); +* +* var v = mode( 0.1 ); +* // returns 0 +* +* v = mode( 1.5 ); +* // returns 0 +*/ + +// MODULES // + +var mode = require( './main.js' ); + + +// EXPORTS // + +module.exports = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/lib/main.js new file mode 100644 index 000000000000..59a3282ae45b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/lib/main.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns the mode of a Planck distribution. +* +* @param {PositiveNumber} lambda - shape parameter +* @returns {NonNegativeInteger} mode +* +* @example +* var v = mode( 0.1 ); +* // returns 0 +* +* @example +* var v = mode( 1.5 ); +* // returns 0 +* +* @example +* var v = mode( -1.1 ); +* // returns NaN +* +* @example +* var v = mode( NaN ); +* // returns NaN +*/ +function mode( lambda ) { + if ( isnan( lambda ) || lambda <= 0.0 ) { + return NaN; + } + return 0; +} + + +// EXPORTS // + +module.exports = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/package.json b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/package.json new file mode 100644 index 000000000000..04c5b8bceac3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/planck/mode", + "version": "0.0.0", + "description": "Planck (discrete exponential) distribution mode.", + "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", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "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": {}, + "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", + "planck", + "parameter", + "memoryless", + "life-time", + "discrete", + "location", + "center", + "mode", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/mode/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/test/test.js new file mode 100644 index 000000000000..1a9f3da7a9e6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/mode/test/test.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 uniform = require( '@stdlib/random/array/uniform' ); +var mode = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mode, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for `lambda`, the function returns `NaN`', function test( t ) { + var v = mode( NaN ); + t.equal( isnan( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a shape parameter `lambda` which is nonpositive, the function returns `NaN`', function test( t ) { + var v; + + v = mode( 0.0 ); + t.equal( isnan( v ), true, 'returns expected value' ); + + v = mode( -1.5 ); + t.equal( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `0.0` as the mode of a Planck distribution', function test( t ) { + var lambda; + var i; + var y; + + lambda = uniform( 10, 0.1, 10.0 ); + + for ( i = 0; i < lambda.length; i++ ) { + y = mode( lambda[ i ] ); + t.equal( y, 0.0, 'returns expected value' ); + } + t.end(); +});