diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/README.md b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/README.md new file mode 100644 index 000000000000..3147d7f90b5c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/README.md @@ -0,0 +1,138 @@ + + +# Mode + +> [Bradford][bradford-distribution] distribution [mode][mode]. + + + +
+ +The [mode][mode] for a [Bradford][bradford-distribution] random variable is + + + +```math +\mathop{\mathrm{mode}}\left( X \right) = 0 +``` + + + + + +where `c` is the shape parameter. + +
+ + + + + +
+ +## Usage + +```javascript +var mode = require( '@stdlib/stats/base/dists/bradford/mode' ); +``` + +#### mode( c ) + +Returns the [mode][mode] of a [Bradford][bradford-distribution] distribution with shape parameter `c`. + +```javascript +var v = mode( 0.1 ); +// returns 0.0 + +v = mode( 10.0 ); +// returns 0.0 +``` + +If provided a shape parameter `c <= 0`, the function returns `NaN`. + +```javascript +var v = mode( 0.0 ); +// returns NaN + +v = mode( -1.5 ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var mode = require( '@stdlib/stats/base/dists/bradford/mode' ); + +var c = uniform( 10, 0.1, 10.0 ); + +var v; +var i; +for ( i = 0; i < c.length; i++ ) { + v = mode( c[ i ] ); + console.log( 'c: %d, mode(X;c): %d', c[ i ].toFixed( 4 ), v.toFixed( 4 ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/benchmark/benchmark.js new file mode 100644 index 000000000000..5f6132132bc6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/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 c; + var y; + var i; + + c = uniform( 100, 0.1, 10.0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = mode( c[ i % c.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/bradford/mode/docs/img/equation_bradford_mode.svg b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/img/equation_bradford_mode.svg new file mode 100644 index 000000000000..e51bc6289018 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/img/equation_bradford_mode.svg @@ -0,0 +1,27 @@ + +normal m times normal o times normal d times normal e left-parenthesis upper X right-parenthesis equals 0 + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/repl.txt new file mode 100644 index 000000000000..44fef0eec6ef --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( c ) + Returns the mode of a Bradford distribution with shape parameter `c`. + + If `c <= 0`, the function returns `NaN`. + + Parameters + ---------- + c: number + Shape parameter. + + Returns + ------- + out: number + Mode. + + Examples + -------- + > var v = {{alias}}( 0.1 ) + 0.0 + > v = {{alias}}( 0.5 ) + 0.0 + > v = {{alias}}( 10.0 ) + 0.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/types/index.d.ts new file mode 100644 index 000000000000..3718abbaede3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the mode of a Bradford distribution. +* +* ## Notes +* +* - If `c <= 0`, the function returns `NaN`. +* +* @param c - shape parameter +* @returns mode +* +* @example +* var v = mode( 0.1 ); +* // returns 0.0 +* +* @example +* var v = mode( 0.5 ); +* // returns 0.0 +* +* @example +* var v = mode( 10.0 ); +* // returns 0.0 +* +* @example +* var v = mode( 0.0 ); +* // returns NaN +* +* @example +* var v = mode( -1.0 ); +* // returns NaN +* +* @example +* var v = mode( NaN ); +* // returns NaN +*/ +declare function mode( c: number ): number; + + +// EXPORTS // + +export = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/docs/types/test.ts new file mode 100644 index 000000000000..a1f70068852e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/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/bradford/mode/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/examples/index.js new file mode 100644 index 000000000000..adf0da56cfbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/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 c = uniform( 10, 0.1, 10.0 ); + +var v; +var i; +for ( i = 0; i < c.length; i++ ) { + v = mode( c[ i ] ); + console.log( 'c: %d, mode(X;c): %d', c[ i ].toFixed( 4 ), v.toFixed( 4 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/index.js new file mode 100644 index 000000000000..fbfe1cd4ea9f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/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'; + +/** +* Bradford distribution mode. +* +* @module @stdlib/stats/base/dists/bradford/mode +* +* @example +* var mode = require( '@stdlib/stats/base/dists/bradford/mode' ); +* +* var v = mode( 0.1 ); +* // returns 0.0 +* +* v = mode( 0.5 ); +* // returns 0.0 +*/ + +// MODULES // + +var mode = require( './main.js' ); + + +// EXPORTS // + +module.exports = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js new file mode 100644 index 000000000000..797e533b6c5b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/lib/main.js @@ -0,0 +1,71 @@ +/** +* @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 Bradford distribution. +* +* @param {PositiveNumber} c - shape parameter +* @returns {NonNegativeNumber} mode +* +* @example +* var v = mode( 0.1 ); +* // returns 0.0 +* +* @example +* var v = mode( 0.5 ); +* // returns 0.0 +* +* @example +* var v = mode( 10.0 ); +* // returns 0.0 +* +* @example +* var v = mode( 0.0 ); +* // returns NaN +* +* @example +* var v = mode( -1.0 ); +* // returns NaN +* +* @example +* var v = mode( NaN ); +* // returns NaN +*/ +function mode( c ) { + if ( + isnan( c ) || + c <= 0.0 + ) { + return NaN; + } + return 0.0; +} + + +// EXPORTS // + +module.exports = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/package.json b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/package.json new file mode 100644 index 000000000000..cfc14d7cc690 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/bradford/mode", + "version": "0.0.0", + "description": "Bradford 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", + "bradford", + "bradford-distribution", + "parameter", + "shape-parameter", + "continuous", + "skewed", + "mode", + "mode-value", + "mode-location" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.js new file mode 100644 index 000000000000..7271072e5913 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/mode/test/test.js @@ -0,0 +1,71 @@ +/** +* @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 NINF = require( '@stdlib/constants/float64/ninf' ); +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 `c`, the function returns `NaN`', function test( t ) { + var v = mode( NaN ); + t.equal( isnan( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided `c <= 0`, the function returns `NaN`', function test( t ) { + var v; + + v = mode( 0.0 ); + t.equal( isnan( v ), true, 'returns expected value' ); + + v = mode( -1.0 ); + t.equal( isnan( v ), true, 'returns expected value' ); + + v = mode( NINF ); + t.equal( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `0.0` as the mode of a Bradford distribution', function test( t ) { + var c; + var i; + var y; + + c = uniform( 10, 0.1, 10.0 ); + + for ( i = 0; i < c.length; i++ ) { + y = mode( c[ i ] ); + t.equal( y, 0.0, 'returns expected value' ); + } + t.end(); +});