From c55d94459c7a179b2cb4dc0856c095655fb2b913 Mon Sep 17 00:00:00 2001 From: Navyansh Kesarwani Date: Mon, 6 Oct 2025 20:14:11 +0530 Subject: [PATCH] feat: added complete implementation for stats/base/dists/halfnormal --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../stats/base/dists/halfnormal/README.md | 247 ++++++++++ .../base/dists/halfnormal/cdf/lib/factory.js | 87 ++++ .../base/dists/halfnormal/cdf/lib/index.js | 51 +++ .../base/dists/halfnormal/cdf/lib/main.js | 84 ++++ .../base/dists/halfnormal/cdf/package.json | 67 +++ .../base/dists/halfnormal/ctor/lib/index.js | 45 ++ .../base/dists/halfnormal/ctor/lib/main.js | 421 ++++++++++++++++++ .../base/dists/halfnormal/ctor/package.json | 68 +++ .../dists/halfnormal/entropy/lib/index.js | 43 ++ .../base/dists/halfnormal/entropy/lib/main.js | 66 +++ .../dists/halfnormal/entropy/package.json | 66 +++ .../dists/halfnormal/kurtosis/lib/index.js | 43 ++ .../dists/halfnormal/kurtosis/lib/main.js | 63 +++ .../dists/halfnormal/kurtosis/package.json | 67 +++ .../stats/base/dists/halfnormal/lib/index.js | 177 ++++++++ .../dists/halfnormal/logcdf/lib/factory.js | 89 ++++ .../base/dists/halfnormal/logcdf/lib/index.js | 51 +++ .../base/dists/halfnormal/logcdf/lib/main.js | 86 ++++ .../base/dists/halfnormal/logcdf/package.json | 68 +++ .../dists/halfnormal/logpdf/lib/factory.js | 97 ++++ .../base/dists/halfnormal/logpdf/lib/index.js | 51 +++ .../base/dists/halfnormal/logpdf/lib/main.js | 99 ++++ .../base/dists/halfnormal/logpdf/package.json | 67 +++ .../base/dists/halfnormal/mean/lib/index.js | 43 ++ .../base/dists/halfnormal/mean/lib/main.js | 62 +++ .../base/dists/halfnormal/mean/package.json | 69 +++ .../base/dists/halfnormal/median/lib/index.js | 43 ++ .../base/dists/halfnormal/median/lib/main.js | 62 +++ .../base/dists/halfnormal/median/package.json | 66 +++ .../base/dists/halfnormal/mgf/lib/factory.js | 97 ++++ .../base/dists/halfnormal/mgf/lib/index.js | 51 +++ .../base/dists/halfnormal/mgf/lib/main.js | 80 ++++ .../base/dists/halfnormal/mgf/package.json | 66 +++ .../base/dists/halfnormal/mode/lib/index.js | 43 ++ .../base/dists/halfnormal/mode/lib/main.js | 60 +++ .../base/dists/halfnormal/mode/package.json | 65 +++ .../stats/base/dists/halfnormal/package.json | 68 +++ .../base/dists/halfnormal/pdf/lib/factory.js | 93 ++++ .../base/dists/halfnormal/pdf/lib/index.js | 51 +++ .../base/dists/halfnormal/pdf/lib/main.js | 98 ++++ .../base/dists/halfnormal/pdf/package.json | 66 +++ .../dists/halfnormal/quantile/lib/factory.js | 91 ++++ .../dists/halfnormal/quantile/lib/index.js | 51 +++ .../dists/halfnormal/quantile/lib/main.js | 92 ++++ .../dists/halfnormal/quantile/package.json | 67 +++ .../dists/halfnormal/skewness/lib/index.js | 43 ++ .../dists/halfnormal/skewness/lib/main.js | 64 +++ .../dists/halfnormal/skewness/package.json | 67 +++ .../base/dists/halfnormal/stdev/lib/index.js | 43 ++ .../base/dists/halfnormal/stdev/lib/main.js | 62 +++ .../base/dists/halfnormal/stdev/package.json | 68 +++ .../dists/halfnormal/variance/lib/index.js | 43 ++ .../dists/halfnormal/variance/lib/main.js | 62 +++ .../dists/halfnormal/variance/package.json | 67 +++ 54 files changed, 4206 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/package.json diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md new file mode 100644 index 000000000000..626a5dac57dd --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md @@ -0,0 +1,247 @@ + + +# Half-Normal + +> Half-normal distribution. + +
+ +## Usage + +```javascript +var halfnormal = require( '@stdlib/stats/base/dists/halfnormal' ); +``` + +#### halfnormal + +Half-normal distribution. + +```javascript +var dist = halfnormal; +// returns {...} +``` + +The namespace contains the following distribution functions: + + + +
+ +- [`cdf( x, sigma )`][@stdlib/stats/base/dists/halfnormal/cdf]: half-normal distribution cumulative distribution function. +- [`logcdf( x, sigma )`][@stdlib/stats/base/dists/halfnormal/logcdf]: evaluate the natural logarithm of the cumulative distribution function (CDF) for a half-normal distribution. +- [`logpdf( x, sigma )`][@stdlib/stats/base/dists/halfnormal/logpdf]: evaluate the natural logarithm of the probability density function (PDF) for a half-normal distribution. +- [`mgf( t, sigma )`][@stdlib/stats/base/dists/halfnormal/mgf]: half-normal distribution moment-generating function (MGF). +- [`pdf( x, sigma )`][@stdlib/stats/base/dists/halfnormal/pdf]: half-normal distribution probability density function (PDF). +- [`quantile( p, sigma )`][@stdlib/stats/base/dists/halfnormal/quantile]: half-normal distribution quantile function. + +
+ + + +The namespace contains the following functions for calculating distribution properties: + + + +
+ +- [`entropy( sigma )`][@stdlib/stats/base/dists/halfnormal/entropy]: half-normal distribution differential entropy. +- [`kurtosis( sigma )`][@stdlib/stats/base/dists/halfnormal/kurtosis]: half-normal distribution excess kurtosis. +- [`mean( sigma )`][@stdlib/stats/base/dists/halfnormal/mean]: half-normal distribution expected value. +- [`median( sigma )`][@stdlib/stats/base/dists/halfnormal/median]: half-normal distribution median. +- [`mode( sigma )`][@stdlib/stats/base/dists/halfnormal/mode]: half-normal distribution mode. +- [`skewness( sigma )`][@stdlib/stats/base/dists/halfnormal/skewness]: half-normal distribution skewness. +- [`stdev( sigma )`][@stdlib/stats/base/dists/halfnormal/stdev]: half-normal distribution standard deviation. +- [`variance( sigma )`][@stdlib/stats/base/dists/halfnormal/variance]: half-normal distribution variance. + +
+ + + +The namespace contains a constructor function for creating a [half-normal][halfnormal-distribution] distribution object. + + + +
+ +- [`HalfNormal( [sigma] )`][@stdlib/stats/base/dists/halfnormal/ctor]: half-normal distribution constructor. + +
+ + + +```javascript +var HalfNormal = require( '@stdlib/stats/base/dists/halfnormal' ).HalfNormal; + +var dist = new HalfNormal( 2.0 ); + +var y = dist.pdf( 1.0 ); +// returns 0.3520653267642996 +``` + +
+ + + +
+ +## Examples + + + +```javascript +var halfnormal = require( '@stdlib/stats/base/dists/halfnormal' ); + +/* +A quality control engineer is analyzing the absolute deviations of product measurements from their target specification. + +The absolute deviations follow a half-normal distribution with scale parameter σ (sigma) = 2.0 mm. + +We can model these absolute deviations using a half-normal distribution with σ = 2.0. +*/ + +var sigma = 2.0; + +var halfnormalDist = new halfnormal.HalfNormal( sigma ); + +// Output the scale parameter: +console.log( halfnormalDist.sigma ); +// => 2.0 + +// Mean absolute deviation: +console.log( halfnormalDist.mean ); +// => ~1.596 + +// Median absolute deviation: +console.log( halfnormalDist.median ); +// => ~1.349 + +// Mode (most common deviation): +console.log( halfnormalDist.mode ); +// => 0.0 + +// Variance of absolute deviations: +console.log( halfnormalDist.variance ); +// => 1.4535209105296745 + +// Probability density function at 1.0 mm deviation: +console.log( halfnormal.pdf( 1.0, sigma ) ); +// => 0.3520653267642996 + +// Cumulative distribution function at 2.0 mm (portion of deviations ≤ 2.0 mm): +console.log( halfnormal.cdf( 2.0, sigma ) ); +// => ~0.683 + +// 90th percentile of absolute deviations: +console.log( halfnormal.quantile( 0.9, sigma ) ); +// => 3.289707253902946 + +// Moment-generating function value at 0.5: +console.log( halfnormal.mgf( 0.5, sigma ) ); +// => 2.7742859576700094 + +// Entropy (measure of uncertainty): +console.log( halfnormal.entropy( sigma ) ); +// => 1.4189385332046727 + +// Skewness (measure of asymmetry): +console.log( halfnormal.skewness( sigma ) ); +// => ~0.995 + +// Excess kurtosis (measure of tail heaviness): +console.log( halfnormal.kurtosis( sigma ) ); +// => ~0.869 + +var myquantile = halfnormal.quantile.factory( 2.0 ); + +// 25th percentile: +console.log( myquantile( 0.25 ) ); +// => 0.6372787279287504 + +// 75th percentile: +console.log( myquantile( 0.75 ) ); +// => 2.300698760752016 + +var mylogpdf = halfnormal.logpdf.factory( 2.0 ); + +// Logarithm of PDF at 1.0 mm: +console.log( mylogpdf( 1.0 ) ); +// => -1.0439385332046727 + +// Logarithm of PDF at 3.0 mm: +console.log( mylogpdf( 3.0 ) ); +// => -2.0439385332046727 +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/factory.js new file mode 100644 index 000000000000..f1a3febb060c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/factory.js @@ -0,0 +1,87 @@ +/** +* @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 constantFunction = require( '@stdlib/utils/constant-function' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var erf = require( '@stdlib/math/base/special/erf' ); + + +// MAIN // + +/** +* Returns a function for evaluating the cumulative distribution function (CDF) for a half-normal distribution. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {Function} function to evaluate the cumulative distribution function +* +* @example +* var cdf = factory( 2.0 ); +* var y = cdf( 1.0 ); +* // returns 0.3829249225480262 +* +* y = cdf( 0.0 ); +* // returns 0.0 +*/ +function factory( sigma ) { + var denom; + if ( + isnan( sigma ) || + sigma < 0.0 + ) { + return constantFunction( NaN ); + } + if ( sigma === 0.0 ) { + return cdf; + } + denom = sigma * sqrt( 2.0 ); + return cdf; + + /** + * Evaluates the cumulative distribution function (CDF) for a half-normal distribution. + * + * @private + * @param {number} x - input value + * @returns {Probability} evaluated cumulative distribution function + * + * @example + * var y = cdf( 2.0 ); + * // returns + */ + function cdf( x ) { + if ( isnan( x ) ) { + return NaN; + } + if ( x < 0.0 ) { + return 0.0; + } + if ( sigma === 0.0 ) { + return ( x >= 0.0 ) ? 1.0 : 0.0; + } + return erf( x / denom ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/index.js new file mode 100644 index 000000000000..4cfe29739554 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/index.js @@ -0,0 +1,51 @@ +/** +* @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'; + +/** +* Half-normal distribution cumulative distribution function (CDF). +* +* @module @stdlib/stats/base/dists/halfnormal/cdf +* +* @example +* var cdf = require( '@stdlib/stats/base/dists/halfnormal/cdf' ); +* +* var y = cdf( 2.0, 1.0 ); +* // returns 0.9544997361036416 +* +* var myCDF = cdf.factory( 2.0 ); +* y = myCDF( 1.0 ); +* // returns 0.3829249225480262 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/main.js new file mode 100644 index 000000000000..b705ba883a7a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/lib/main.js @@ -0,0 +1,84 @@ +/** +* @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 erf = require( '@stdlib/math/base/special/erf' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Evaluates the cumulative distribution function (CDF) for a half-normal distribution with scale parameter `sigma` at a value `x`. +* +* @param {number} x - input value +* @param {PositiveNumber} sigma - scale parameter +* @returns {Probability} evaluated cumulative distribution function +* +* @example +* var y = cdf( 2.0, 1.0 ); +* // returns 0.9544997361036416 +* +* @example +* var y = cdf( -1.0, 2.0 ); +* // returns 0.0 +* +* @example +* var y = cdf( 0.0, 1.0 ); +* // returns 0.0 +* +* @example +* var y = cdf( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = cdf( 0.0, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = cdf( 2.0, -1.0 ); +* // returns NaN +*/ +function cdf( x, sigma ) { + var denom; + if ( + isnan( x ) || + isnan( sigma ) || + sigma < 0.0 + ) { + return NaN; + } + if ( x < 0.0 ) { + return 0.0; + } + if ( sigma === 0.0 ) { + return ( x >= 0.0 ) ? 1.0 : 0.0; + } + denom = sigma * sqrt( 2.0 ); + return erf( x / denom ); +} + + +// EXPORTS // + +module.exports = cdf; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/package.json new file mode 100644 index 000000000000..1290f969f3a0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/cdf/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/cdf", + "version": "0.0.0", + "description": "Half-normal distribution cumulative distribution function (CDF).", + "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", + "continuous", + "probability", + "cdf", + "halfnormal", + "half-normal", + "half normal", + "univariate", + "cumulative" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/index.js new file mode 100644 index 000000000000..754569c2c7d7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/index.js @@ -0,0 +1,45 @@ +/** +* @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'; + +/** +* Half-normal distribution constructor. +* +* @module @stdlib/stats/base/dists/halfnormal/ctor +* +* @example +* var HalfNormal = require( '@stdlib/stats/base/dists/halfnormal/ctor' ); +* +* var halfnormal = new HalfNormal( 2.0 ); +* +* var y = halfnormal.cdf( 0.8 ); +* // returns ~0.31 +* +* var v = halfnormal.mode; +* // returns 0.0 +*/ + +// MODULES // + +var ctor = require( './main.js' ); + + +// EXPORTS // + +module.exports = ctor; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/main.js new file mode 100644 index 000000000000..c7634c95ecfe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/lib/main.js @@ -0,0 +1,421 @@ +/** +* @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. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var defineProperty = require( '@stdlib/utils/define-property' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); +var isPositive = require( '@stdlib/assert/is-positive-number' ).isPrimitive; +var entropy = require( '@stdlib/stats/base/dists/halfnormal/entropy' ); +var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); +var mean = require( '@stdlib/stats/base/dists/halfnormal/mean' ); +var median = require( '@stdlib/stats/base/dists/halfnormal/median' ); +var mode = require( '@stdlib/stats/base/dists/halfnormal/mode' ); +var skewness = require( '@stdlib/stats/base/dists/halfnormal/skewness' ); +var stdev = require( '@stdlib/stats/base/dists/halfnormal/stdev' ); +var variance = require( '@stdlib/stats/base/dists/halfnormal/variance' ); +var cdf = require( '@stdlib/stats/base/dists/halfnormal/cdf' ); +var logcdf = require( '@stdlib/stats/base/dists/halfnormal/logcdf' ); +var logpdf = require( '@stdlib/stats/base/dists/halfnormal/logpdf' ); +var mgf = require( '@stdlib/stats/base/dists/halfnormal/mgf' ); +var pdf = require( '@stdlib/stats/base/dists/halfnormal/pdf' ); +var quantile = require( '@stdlib/stats/base/dists/halfnormal/quantile' ); +var format = require( '@stdlib/string/format' ); + + +// FUNCTIONS // + +/** +* Evaluates the cumulative distribution function (CDF). +* +* @private +* @param {number} x - input value +* @returns {Probability} evaluated CDF +*/ +function halfnormalCDF( x ) { + return cdf( x, this.sigma ); +} + +/** +* Evaluates the natural logarithm of the cumulative distribution function (CDF). +* +* @private +* @param {number} x - input value +* @returns {number} evaluated logCDF +*/ +function halfnormalLogCDF( x ) { + return logcdf( x, this.sigma ); +} + +/** +* Evaluates the natural logarithm of the probability density function (PDF). +* +* @private +* @param {number} x - input value +* @returns {number} evaluated logPDF +*/ +function halfnormalLogPDF( x ) { + return logpdf( x, this.sigma ); +} + +/** +* Evaluates the moment-generating function (MGF). +* +* @private +* @param {number} t - input value +* @returns {number} evaluated MGF +*/ +function halfnormalMGF( t ) { + return mgf( t, this.sigma ); +} + +/** +* Evaluates the probability density function (PDF). +* +* @private +* @param {number} x - input value +* @returns {number} evaluated PDF +*/ +function halfnormalPDF( x ) { + return pdf( x, this.sigma ); +} + +/** +* Evaluates the quantile function. +* +* @private +* @param {Probability} p - input probability +* @returns {number} evaluated quantile function +*/ +function halfnormalQuantile( p ) { + return quantile( p, this.sigma ); +} + + +// MAIN // + +/** +* Half-normal distribution constructor. +* +* @constructor +* @param {PositiveNumber} [sigma=1.0] - scale parameter +* @throws {TypeError} `sigma` must be a positive number +* @returns {HalfNormal} distribution instance +* +* @example +* var halfnormal = new HalfNormal( 1.0 ); +* +* var y = halfnormal.cdf( 1.5 ); +* // returns ~0.866 +* +* var v = halfnormal.mean; +* // returns ~0.798 +*/ +function HalfNormal() { + var sigma; + if ( !(this instanceof HalfNormal) ) { + if ( arguments.length === 0 ) { + return new HalfNormal(); + } + return new HalfNormal( arguments[ 0 ] ); + } + if ( arguments.length ) { + sigma = arguments[ 0 ]; + if ( !isPositive( sigma ) ) { + throw new TypeError( format( 'invalid argument. Scale parameter must be a positive number. Value: `%s`.', sigma ) ); + } + } else { + sigma = 1.0; + } + defineProperty( this, 'sigma', { + 'configurable': false, + 'enumerable': true, + 'get': function get() { + return sigma; + }, + 'set': function set( value ) { + if ( !isPositive( value ) ) { + throw new TypeError( format( 'invalid assignment. Must be a positive number. Value: `%s`.', value ) ); + } + sigma = value; + } + }); + return this; +} + +/** +* Half-normal distribution differential entropy. +* +* @name entropy +* @memberof HalfNormal.prototype +* @type {number} +* @see [differential entropy]{@link https://en.wikipedia.org/wiki/Entropy_%28information_theory%29} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.entropy; +* // returns 2.112085713764618 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'entropy', function get() { + return entropy( this.sigma ); +}); + +/** +* Half-normal distribution excess kurtosis. +* +* @name kurtosis +* @memberof HalfNormal.prototype +* @type {number} +* @see [kurtosis]{@link https://en.wikipedia.org/wiki/Kurtosis} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.kurtosis; +* // returns ~0.869 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'kurtosis', function get() { + return kurtosis( this.sigma ); +}); + +/** +* Half-normal distribution expected value. +* +* @name mean +* @memberof HalfNormal.prototype +* @type {number} +* @see [expected value]{@link https://en.wikipedia.org/wiki/Expected_value} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.mean; +* // returns 3.1915382432114616 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'mean', function get() { + return mean( this.sigma ); +}); + +/** +* Half-normal distribution median. +* +* @name median +* @memberof HalfNormal.prototype +* @type {number} +* @see [median]{@link https://en.wikipedia.org/wiki/Median} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.median; +* // returns ~2.698 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'median', function get() { + return median( this.sigma ); +}); + +/** +* Half-normal distribution mode. +* +* @name mode +* @memberof HalfNormal.prototype +* @type {number} +* @see [mode]{@link https://en.wikipedia.org/wiki/Mode_%28statistics%29} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.mode; +* // returns 0.0 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'mode', function get() { + return mode( this.sigma ); +}); + +/** +* Half-normal distribution skewness. +* +* @name skewness +* @memberof HalfNormal.prototype +* @type {number} +* @see [skewness]{@link https://en.wikipedia.org/wiki/Skewness} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.skewness; +* // returns ~0.995 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'skewness', function get() { + return skewness( this.sigma ); +}); + +/** +* Half-normal distribution standard deviation. +* +* @name stdev +* @memberof HalfNormal.prototype +* @type {PositiveNumber} +* @see [standard deviation]{@link https://en.wikipedia.org/wiki/Standard_deviation} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.stdev; +* // returns ~2.411 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'stdev', function get() { + return stdev( this.sigma ); +}); + +/** +* Half-normal distribution variance. +* +* @name variance +* @memberof HalfNormal.prototype +* @type {PositiveNumber} +* @see [variance]{@link https://en.wikipedia.org/wiki/Variance} +* +* @example +* var halfnormal = new HalfNormal( 4.0 ); +* +* var v = halfnormal.variance; +* // returns ~5.814 +*/ +setReadOnlyAccessor( HalfNormal.prototype, 'variance', function get() { + return variance( this.sigma ); +}); + +/** +* Evaluates the cumulative distribution function (CDF). +* +* @name cdf +* @memberof HalfNormal.prototype +* @type {Function} +* @param {number} x - input value +* @returns {number} evaluated CDF +* @see [cdf]{@link https://en.wikipedia.org/wiki/Cumulative_distribution_function} +* +* @example +* var halfnormal = new HalfNormal( 2.0 ); +* +* var v = halfnormal.cdf( 0.5 ); +* // returns 0.19741265136584743 +*/ +setReadOnly( HalfNormal.prototype, 'cdf', halfnormalCDF ); + +/** +* Evaluates the natural logarithm of the cumulative distribution function (CDF). +* +* @name logcdf +* @memberof HalfNormal.prototype +* @type {Function} +* @param {number} x - input value +* @returns {number} evaluated logCDF +* @see [cdf]{@link https://en.wikipedia.org/wiki/Cumulative_distribution_function} +* +* @example +* var halfnormal = new HalfNormal( 2.0 ); +* +* var v = halfnormal.logcdf( 0.5 ); +* // returns -1.622459064037205 +*/ +setReadOnly( HalfNormal.prototype, 'logcdf', halfnormalLogCDF ); + +/** +* Evaluates the natural logarithm of the probability density function (PDF). +* +* @name logpdf +* @memberof HalfNormal.prototype +* @type {Function} +* @param {number} x - input value +* @returns {number} evaluated logPDF +* @see [pdf]{@link https://en.wikipedia.org/wiki/Probability_density_function} +* +* @example +* var halfnormal = new HalfNormal( 2.0 ); +* +* var v = halfnormal.logpdf( 0.8 ); +* // returns ~-1.0 +*/ +setReadOnly( HalfNormal.prototype, 'logpdf', halfnormalLogPDF ); + +/** +* Evaluates the moment-generating function (MGF). +* +* @name mgf +* @memberof HalfNormal.prototype +* @type {Function} +* @param {number} t - input value +* @returns {number} evaluated MGF +* @see [mgf]{@link https://en.wikipedia.org/wiki/Moment-generating_function} +* +* @example +* var halfnormal = new HalfNormal( 2.0 ); +* +* var v = halfnormal.mgf( 0.5 ); +* // returns 2.7742859576700094 +*/ +setReadOnly( HalfNormal.prototype, 'mgf', halfnormalMGF ); + +/** +* Evaluates the probability density function (PDF). +* +* @name pdf +* @memberof HalfNormal.prototype +* @type {Function} +* @param {number} x - input value +* @returns {number} evaluated PDF +* @see [pdf]{@link https://en.wikipedia.org/wiki/Probability_density_function} +* +* @example +* var halfnormal = new HalfNormal( 2.0 ); +* +* var v = halfnormal.pdf( 0.8 ); +* // returns ~0.368 +*/ +setReadOnly( HalfNormal.prototype, 'pdf', halfnormalPDF ); + +/** +* Evaluates the quantile function. +* +* @name quantile +* @memberof HalfNormal.prototype +* @type {Function} +* @param {Probability} p - input probability +* @returns {number} evaluated quantile function +* @see [quantile function]{@link https://en.wikipedia.org/wiki/Quantile_function} +* +* @example +* var halfnormal = new HalfNormal( 2.0 ); +* +* var v = halfnormal.quantile( 0.5 ); +* // returns ~1.349 +*/ +setReadOnly( HalfNormal.prototype, 'quantile', halfnormalQuantile ); + + +// EXPORTS // + +module.exports = HalfNormal; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/package.json new file mode 100644 index 000000000000..3972e1099316 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/ctor/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/ctor", + "version": "0.0.0", + "description": "Half-normal distribution constructor.", + "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", + "continuous", + "probability", + "halfnormal", + "half-normal", + "univariate", + "constructor", + "ctor", + "class", + "object" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/index.js new file mode 100644 index 000000000000..5af6d0522b4e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/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'; + +/** +* Half-normal distribution differential entropy. +* +* @module @stdlib/stats/base/dists/halfnormal/entropy +* +* @example +* var entropy = require( '@stdlib/stats/base/dists/halfnormal/entropy' ); +* +* var y = entropy( 1.0 ); +* // returns 0.7257913526447274 +* +* y = entropy( 4.0 ); +* // returns 2.112085713764618 +*/ + +// MODULES // + +var entropy = require( './main.js' ); + + +// EXPORTS // + +module.exports = entropy; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/main.js new file mode 100644 index 000000000000..2f0c2c78606c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/lib/main.js @@ -0,0 +1,66 @@ +/** +* @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' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var PI = require( '@stdlib/constants/float64/pi' ); + + +// MAIN // + +/** +* Returns the differential entropy of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} differential entropy +* +* @example +* var y = entropy( 1.0 ); +* // returns 0.7257913526447274 +* +* @example +* var y = entropy( 4.0 ); +* // returns 2.112085713764618 +* +* @example +* var y = entropy( NaN ); +* // returns NaN +* +* @example +* var y = entropy( -1.0 ); +* // returns NaN +*/ +function entropy( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + if ( sigma === 0.0 ) { + return -Infinity; + } + // Entropy = 0.5 * ln(PI * sigma^2 / 2) + 0.5 + return ( 0.5 * ln( ( PI * sigma * sigma ) / 2.0 ) ) + 0.5; +} + + +// EXPORTS // + +module.exports = entropy; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/package.json new file mode 100644 index 000000000000..bf1e360ede58 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/entropy/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/entropy", + "version": "0.0.0", + "description": "Half-normal 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", + "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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "entropy", + "differential entropy", + "information" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/index.js new file mode 100644 index 000000000000..90764a380f35 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/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'; + +/** +* Half-normal distribution excess kurtosis. +* +* @module @stdlib/stats/base/dists/halfnormal/kurtosis +* +* @example +* var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); +* +* var y = kurtosis( 1.0 ); +* // returns ~0.869 +* +* y = kurtosis( 4.0 ); +* // returns ~0.869 +*/ + +// MODULES // + +var kurtosis = require( './main.js' ); + + +// EXPORTS // + +module.exports = kurtosis; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js new file mode 100644 index 000000000000..6a8beefeb8ab --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js @@ -0,0 +1,63 @@ +/** +* @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' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var PI = require( '@stdlib/constants/float64/pi' ); + + +// MAIN // + +/** +* Returns the excess kurtosis of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} excess kurtosis +* +* @example +* var y = kurtosis( 1.0 ); +* // returns ~0.869 +* +* @example +* var y = kurtosis( 4.0 ); +* // returns ~0.869 +* +* @example +* var y = kurtosis( NaN ); +* // returns NaN +* +* @example +* var y = kurtosis( -1.0 ); +* // returns NaN +*/ +function kurtosis( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + // Excess kurtosis = (8 * (PI - 3)) / (PI - 2)^2 + return ( 8.0 * ( PI - 3.0 ) ) / pow( PI - 2.0, 2.0 ); +} + + +// EXPORTS // + +module.exports = kurtosis; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json new file mode 100644 index 000000000000..11a924cc06cb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/kurtosis", + "version": "0.0.0", + "description": "Half-normal distribution excess kurtosis.", + "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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "kurtosis", + "excess kurtosis", + "shape", + "tailedness" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js new file mode 100644 index 000000000000..33dac5afbba7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js @@ -0,0 +1,177 @@ +/** +* @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'; + +/* +* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); + + +// MAIN // + +/** +* Top-level namespace. +* +* @namespace halfnormal +*/ +var halfnormal = {}; + +/** +* @name cdf +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/cdf} +*/ +setReadOnly( halfnormal, 'cdf', require( '@stdlib/stats/base/dists/halfnormal/cdf' ) ); + +/** +* @name HalfNormal +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/ctor} +*/ +setReadOnly( halfnormal, 'HalfNormal', require( '@stdlib/stats/base/dists/halfnormal/ctor' ) ); + +/** +* @name entropy +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/entropy} +*/ +setReadOnly( halfnormal, 'entropy', require( '@stdlib/stats/base/dists/halfnormal/entropy' ) ); + +/** +* @name kurtosis +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/kurtosis} +*/ +setReadOnly( halfnormal, 'kurtosis', require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ) ); + +/** +* @name logcdf +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/logcdf} +*/ +setReadOnly( halfnormal, 'logcdf', require( '@stdlib/stats/base/dists/halfnormal/logcdf' ) ); + +/** +* @name logpdf +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/logpdf} +*/ +setReadOnly( halfnormal, 'logpdf', require( '@stdlib/stats/base/dists/halfnormal/logpdf' ) ); + +/** +* @name mean +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/mean} +*/ +setReadOnly( halfnormal, 'mean', require( '@stdlib/stats/base/dists/halfnormal/mean' ) ); + +/** +* @name median +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/median} +*/ +setReadOnly( halfnormal, 'median', require( '@stdlib/stats/base/dists/halfnormal/median' ) ); + +/** +* @name mgf +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/mgf} +*/ +setReadOnly( halfnormal, 'mgf', require( '@stdlib/stats/base/dists/halfnormal/mgf' ) ); + +/** +* @name mode +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/mode} +*/ +setReadOnly( halfnormal, 'mode', require( '@stdlib/stats/base/dists/halfnormal/mode' ) ); + +/** +* @name pdf +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/pdf} +*/ +setReadOnly( halfnormal, 'pdf', require( '@stdlib/stats/base/dists/halfnormal/pdf' ) ); + +/** +* @name quantile +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/quantile} +*/ +setReadOnly( halfnormal, 'quantile', require( '@stdlib/stats/base/dists/halfnormal/quantile' ) ); + +/** +* @name skewness +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/skewness} +*/ +setReadOnly( halfnormal, 'skewness', require( '@stdlib/stats/base/dists/halfnormal/skewness' ) ); + +/** +* @name stdev +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/stdev} +*/ +setReadOnly( halfnormal, 'stdev', require( '@stdlib/stats/base/dists/halfnormal/stdev' ) ); + +/** +* @name variance +* @memberof halfnormal +* @readonly +* @type {Function} +* @see {@link module:@stdlib/stats/base/dists/halfnormal/variance} +*/ +setReadOnly( halfnormal, 'variance', require( '@stdlib/stats/base/dists/halfnormal/variance' ) ); + + +// EXPORTS // + +module.exports = halfnormal; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/factory.js new file mode 100644 index 000000000000..d8a8dbf6955a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/factory.js @@ -0,0 +1,89 @@ +/** +* @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 constantFunction = require( '@stdlib/utils/constant-function' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var erf = require( '@stdlib/math/base/special/erf' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// MAIN // + +/** +* Returns a function for evaluating the natural logarithm of the cumulative distribution function (CDF) for a half-normal distribution. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {Function} function to evaluate the natural logarithm of the cumulative distribution function +* +* @example +* var logcdf = factory( 2.0 ); +* var y = logcdf( 1.0 ); +* // returns -0.9599163336956225 +* +* y = logcdf( 0.0 ); +* // returns -Infinity +*/ +function factory( sigma ) { + var denom; + if ( + isnan( sigma ) || + sigma < 0.0 + ) { + return constantFunction( NaN ); + } + if ( sigma === 0.0 ) { + return logcdf; + } + denom = sigma * sqrt( 2.0 ); + return logcdf; + + /** + * Evaluates the natural logarithm of the cumulative distribution function (CDF) for a half-normal distribution. + * + * @private + * @param {number} x - input value + * @returns {number} evaluated natural logarithm of CDF + * + * @example + * var y = logcdf( 2.0 ); + * // returns + */ + function logcdf( x ) { + if ( isnan( x ) ) { + return NaN; + } + if ( x < 0.0 ) { + return NINF; + } + if ( sigma === 0.0 ) { + return ( x >= 0.0 ) ? 0.0 : NINF; + } + return ln( erf( x / denom ) ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/index.js new file mode 100644 index 000000000000..dea3efa45093 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/index.js @@ -0,0 +1,51 @@ +/** +* @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'; + +/** +* Half-normal distribution natural logarithm of cumulative distribution function (CDF). +* +* @module @stdlib/stats/base/dists/halfnormal/logcdf +* +* @example +* var logcdf = require( '@stdlib/stats/base/dists/halfnormal/logcdf' ); +* +* var y = logcdf( 2.0, 1.0 ); +* // returns -0.046567912292390164 +* +* var myLogCDF = logcdf.factory( 2.0 ); +* y = myLogCDF( 1.0 ); +* // returns -0.9599163336956225 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/main.js new file mode 100644 index 000000000000..0ababc0aaae2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/lib/main.js @@ -0,0 +1,86 @@ +/** +* @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' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var erf = require( '@stdlib/math/base/special/erf' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// MAIN // + +/** +* Evaluates the natural logarithm of the cumulative distribution function (CDF) for a half-normal distribution with scale parameter `sigma` at a value `x`. +* +* @param {number} x - input value +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} evaluated natural logarithm of CDF +* +* @example +* var y = logcdf( 2.0, 1.0 ); +* // returns -0.046567912292390164 +* +* @example +* var y = logcdf( -1.0, 2.0 ); +* // returns -Infinity +* +* @example +* var y = logcdf( 0.0, 1.0 ); +* // returns -Infinity +* +* @example +* var y = logcdf( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = logcdf( 0.0, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = logcdf( 2.0, -1.0 ); +* // returns NaN +*/ +function logcdf( x, sigma ) { + var denom; + if ( + isnan( x ) || + isnan( sigma ) || + sigma < 0.0 + ) { + return NaN; + } + if ( x < 0.0 ) { + return NINF; + } + if ( sigma === 0.0 ) { + return ( x >= 0.0 ) ? 0.0 : NINF; + } + denom = sigma * sqrt( 2.0 ); + return ln( erf( x / denom ) ); +} + + +// EXPORTS // + +module.exports = logcdf; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/package.json new file mode 100644 index 000000000000..5046da8ab6da --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logcdf/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/logcdf", + "version": "0.0.0", + "description": "Half-normal distribution logarithm of cumulative distribution function (CDF).", + "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", + "continuous", + "probability", + "logcdf", + "log", + "logarithm", + "halfnormal", + "half-normal", + "univariate", + "cumulative" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/factory.js new file mode 100644 index 000000000000..b74096261eae --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/factory.js @@ -0,0 +1,97 @@ +/** +* @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 constantFunction = require( '@stdlib/utils/constant-function' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var LN_SQRT_TWO_PI = require( '@stdlib/constants/float64/ln-sqrt-two-pi' ); + + +// VARIABLES // + +var LN_SQRT2 = 0.34657359027997265; // ln(sqrt(2)) + + +// MAIN // + +/** +* Returns a function for evaluating the natural logarithm of the probability density function (PDF) for a half-normal distribution. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {Function} function to evaluate the natural logarithm of the probability density function +* +* @example +* var logpdf = factory( 2.0 ); +* var y = logpdf( 1.0 ); +* // returns -1.0439385332046727 +* +* y = logpdf( 0.0 ); +* // returns -0.9189385332046727 +*/ +function factory( sigma ) { + var s2; + var A; + if ( + isnan( sigma ) || + sigma < 0.0 + ) { + return constantFunction( NaN ); + } + if ( sigma === 0.0 ) { + return logpdf; + } + s2 = pow( sigma, 2.0 ); + A = LN_SQRT2 - ln( sigma ) - LN_SQRT_TWO_PI + ( 0.5 * ln( 2.0 ) ); + return logpdf; + + /** + * Evaluates the natural logarithm of the probability density function (PDF) for a half-normal distribution. + * + * @private + * @param {number} x - input value + * @returns {number} evaluated natural logarithm of PDF + * + * @example + * var y = logpdf( 2.0 ); + * // returns + */ + function logpdf( x ) { + if ( isnan( x ) ) { + return NaN; + } + if ( x < 0.0 ) { + return NINF; + } + if ( sigma === 0.0 ) { + return ( x === 0.0 ) ? PINF : NINF; + } + return A - ( pow( x, 2.0 ) / ( 2.0 * s2 ) ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/index.js new file mode 100644 index 000000000000..4da6ff4af4b8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/index.js @@ -0,0 +1,51 @@ +/** +* @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'; + +/** +* Half-normal distribution natural logarithm of probability density function (PDF). +* +* @module @stdlib/stats/base/dists/halfnormal/logpdf +* +* @example +* var logpdf = require( '@stdlib/stats/base/dists/halfnormal/logpdf' ); +* +* var y = logpdf( 2.0, 1.0 ); +* // returns -2.2257913526447274 +* +* var myLogPDF = logpdf.factory( 2.0 ); +* y = myLogPDF( 1.0 ); +* // returns -1.0439385332046727 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/main.js new file mode 100644 index 000000000000..6867c7ad5337 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/lib/main.js @@ -0,0 +1,99 @@ +/** +* @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' ); +var ln = require( '@stdlib/math/base/special/ln' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var LN_SQRT_TWO_PI = require( '@stdlib/constants/float64/ln-sqrt-two-pi' ); + + +// VARIABLES // + +var LN_SQRT2 = 0.34657359027997265; // ln(sqrt(2)) + + +// MAIN // + +/** +* Evaluates the natural logarithm of the probability density function (PDF) for a half-normal distribution with scale parameter `sigma` at a value `x`. +* +* @param {number} x - input value +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} evaluated natural logarithm of PDF +* +* @example +* var y = logpdf( 2.0, 1.0 ); +* // returns -2.2257913526447274 +* +* @example +* var y = logpdf( -1.0, 2.0 ); +* // returns -Infinity +* +* @example +* var y = logpdf( 0.0, 1.0 ); +* // returns -0.22579135264472743 +* +* @example +* var y = logpdf( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = logpdf( 0.0, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = logpdf( 2.0, -1.0 ); +* // returns NaN +*/ +function logpdf( x, sigma ) { + var s2; + if ( + isnan( x ) || + isnan( sigma ) || + sigma < 0.0 + ) { + return NaN; + } + if ( x < 0.0 ) { + return NINF; + } + if ( sigma === 0.0 ) { + return ( x === 0.0 ) ? PINF : NINF; + } + s2 = pow( sigma, 2.0 ); + + // log(sqrt(2) / (sigma * sqrt(PI))) - x^2 / (2*sigma^2) + + // = log(sqrt(2)) - log(sigma) - log(sqrt(PI)) - x^2 / (2*sigma^2) + + // = log(sqrt(2)) - log(sigma) - 0.5*log(PI) - x^2 / (2*sigma^2) + return LN_SQRT2 - ln( sigma ) - LN_SQRT_TWO_PI + + ( 0.5 * ln( 2.0 ) ) - ( pow( x, 2.0 ) / ( 2.0 * s2 ) ); +} + + +// EXPORTS // + +module.exports = logpdf; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/package.json new file mode 100644 index 000000000000..8df14d6e485f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/logpdf/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/logpdf", + "version": "0.0.0", + "description": "Half-normal distribution logarithm of probability density function (PDF).", + "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", + "continuous", + "probability", + "logpdf", + "log", + "logarithm", + "halfnormal", + "half-normal", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/index.js new file mode 100644 index 000000000000..ef2ac893af0c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/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'; + +/** +* Half-normal distribution expected value. +* +* @module @stdlib/stats/base/dists/halfnormal/mean +* +* @example +* var mean = require( '@stdlib/stats/base/dists/halfnormal/mean' ); +* +* var y = mean( 1.0 ); +* // returns 0.7978845608028654 +* +* y = mean( 4.0 ); +* // returns 3.1915382432114616 +*/ + +// MODULES // + +var mean = require( './main.js' ); + + +// EXPORTS // + +module.exports = mean; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/main.js new file mode 100644 index 000000000000..bd1f352f0980 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var PI = require( '@stdlib/constants/float64/pi' ); + + +// MAIN // + +/** +* Returns the expected value of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {PositiveNumber} expected value +* +* @example +* var y = mean( 1.0 ); +* // returns 0.7978845608028654 +* +* @example +* var y = mean( 4.0 ); +* // returns 3.1915382432114616 +* +* @example +* var y = mean( NaN ); +* // returns NaN +* +* @example +* var y = mean( -1.0 ); +* // returns NaN +*/ +function mean( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + return sigma * sqrt( 2.0 / PI ); +} + + +// EXPORTS // + +module.exports = mean; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/package.json new file mode 100644 index 000000000000..4c3352278442 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mean/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/mean", + "version": "0.0.0", + "description": "Half-normal distribution expected value.", + "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", + "continuous", + "halfnormal", + "half-normal", + "half normal", + "univariate", + "mean", + "expected value", + "expectation", + "center", + "mu" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/index.js new file mode 100644 index 000000000000..e06509334a84 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/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'; + +/** +* Half-normal distribution median. +* +* @module @stdlib/stats/base/dists/halfnormal/median +* +* @example +* var median = require( '@stdlib/stats/base/dists/halfnormal/median' ); +* +* var y = median( 1.0 ); +* // returns 0.6744897501960817 +* +* y = median( 4.0 ); +* // returns 2.697959000784327 +*/ + +// MODULES // + +var median = require( './main.js' ); + + +// EXPORTS // + +module.exports = median; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/main.js new file mode 100644 index 000000000000..2574b019d0f7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var erfinv = require( '@stdlib/math/base/special/erfinv' ); + + +// MAIN // + +/** +* Returns the median of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {PositiveNumber} median +* +* @example +* var y = median( 1.0 ); +* // returns 0.6744897501960817 +* +* @example +* var y = median( 4.0 ); +* // returns 2.697959000784327 +* +* @example +* var y = median( NaN ); +* // returns NaN +* +* @example +* var y = median( -1.0 ); +* // returns NaN +*/ +function median( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + return sigma * sqrt( 2.0 ) * erfinv( 0.5 ); +} + + +// EXPORTS // + +module.exports = median; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/package.json new file mode 100644 index 000000000000..6a8c8a6e6c01 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/median/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/median", + "version": "0.0.0", + "description": "Half-normal distribution median.", + "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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "median", + "center", + "middle" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/factory.js new file mode 100644 index 000000000000..0fcf580891ea --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/factory.js @@ -0,0 +1,97 @@ +/** +* @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 constantFunction = require( '@stdlib/utils/constant-function' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var exp = require( '@stdlib/math/base/special/exp' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var erfc = require( '@stdlib/math/base/special/erfc' ); +var SQRT2 = require( '@stdlib/constants/float64/sqrt-two' ); + + +// FUNCTIONS // + +/** +* Evaluates the moment-generating function (MGF) for a degenerate distribution. +* +* @private +* @param {number} t - input value +* @returns {number} evaluated MGF +*/ +function mgf0( t ) { + return ( t === 0.0 ) ? 1.0 : NaN; +} + + +// MAIN // + +/** +* Returns a function for evaluating the moment-generating function (MGF) for a half-normal distribution. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {Function} function to evaluate the moment-generating function +* +* @example +* var mgf = factory( 2.0 ); +* var y = mgf( 0.5 ); +* // returns 2.7742859576700094 +* +* y = mgf( 0.0 ); +* // returns 1.0 +*/ +function factory( sigma ) { + if ( + isnan( sigma ) || + sigma < 0.0 + ) { + return constantFunction( NaN ); + } + if ( sigma === 0.0 ) { + return mgf0; + } + return mgf; + + /** + * Evaluates the moment-generating function (MGF) for a half-normal distribution. + * + * @private + * @param {number} t - input value + * @returns {number} evaluated MGF + * + * @example + * var y = mgf( 0.5 ); + * // returns + */ + function mgf( t ) { + var st; + if ( isnan( t ) ) { + return NaN; + } + st = sigma * t; + return exp( pow( st, 2.0 ) / 2.0 ) * erfc( -st / SQRT2 ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/index.js new file mode 100644 index 000000000000..9640684922fc --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/index.js @@ -0,0 +1,51 @@ +/** +* @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'; + +/** +* Half-normal distribution moment-generating function (MGF). +* +* @module @stdlib/stats/base/dists/halfnormal/mgf +* +* @example +* var mgf = require( '@stdlib/stats/base/dists/halfnormal/mgf' ); +* +* var y = mgf( 0.5, 1.0 ); +* // returns 1.5670592366928566 +* +* var myMGF = mgf.factory( 2.0 ); +* y = myMGF( 0.5 ); +* // returns 2.7742859576700094 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/main.js new file mode 100644 index 000000000000..47dc175f8817 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/lib/main.js @@ -0,0 +1,80 @@ +/** +* @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' ); +var exp = require( '@stdlib/math/base/special/exp' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var erfc = require( '@stdlib/math/base/special/erfc' ); +var SQRT2 = require( '@stdlib/constants/float64/sqrt-two' ); + + +// MAIN // + +/** +* Evaluates the moment-generating function (MGF) for a half-normal distribution with scale parameter `sigma` at a value `t`. +* +* @param {number} t - input value +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} evaluated MGF +* +* @example +* var y = mgf( 0.0, 1.0 ); +* // returns 1.0 +* +* @example +* var y = mgf( 0.5, 1.0 ); +* // returns 1.5670592366928566 +* +* @example +* var y = mgf( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = mgf( 0.0, NaN ); +* // returns NaN +* +* @example +* var y = mgf( 0.5, -1.0 ); +* // returns NaN +*/ +function mgf( t, sigma ) { + var st; + if ( + isnan( t ) || + isnan( sigma ) || + sigma < 0.0 + ) { + return NaN; + } + if ( sigma === 0.0 ) { + return ( t === 0.0 ) ? 1.0 : NaN; + } + st = sigma * t; + + // MGF = exp(sigma^2 * t^2 / 2) * erfc(-sigma * t / sqrt(2)) + return exp( pow( st, 2.0 ) / 2.0 ) * erfc( -st / SQRT2 ); +} + + +// EXPORTS // + +module.exports = mgf; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/package.json new file mode 100644 index 000000000000..e83fd835436a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mgf/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/mgf", + "version": "0.0.0", + "description": "Half-normal distribution moment-generating function (MGF).", + "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", + "continuous", + "probability", + "mgf", + "moment-generating function", + "halfnormal", + "half-normal", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/lib/index.js new file mode 100644 index 000000000000..1975415ab1ee --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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'; + +/** +* Half-normal distribution mode. +* +* @module @stdlib/stats/base/dists/halfnormal/mode +* +* @example +* var mode = require( '@stdlib/stats/base/dists/halfnormal/mode' ); +* +* var y = mode( 1.0 ); +* // returns 0.0 +* +* y = mode( 4.0 ); +* // returns 0.0 +*/ + +// MODULES // + +var mode = require( './main.js' ); + + +// EXPORTS // + +module.exports = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/lib/main.js new file mode 100644 index 000000000000..b114c51bbbfb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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 half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {NonNegativeNumber} mode +* +* @example +* var y = mode( 1.0 ); +* // returns 0.0 +* +* @example +* var y = mode( 4.0 ); +* // returns 0.0 +* +* @example +* var y = mode( NaN ); +* // returns NaN +* +* @example +* var y = mode( -1.0 ); +* // returns NaN +*/ +function mode( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + return 0.0; +} + + +// EXPORTS // + +module.exports = mode; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/package.json new file mode 100644 index 000000000000..31567a20a6e1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/mode/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/mode", + "version": "0.0.0", + "description": "Half-normal 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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "mode", + "peak" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/package.json new file mode 100644 index 000000000000..00c6689c705b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal", + "version": "0.0.0", + "description": "Half-normal distribution.", + "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": { + "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", + "standard", + "library", + "std", + "lib", + "statistics", + "stats", + "probability", + "distribution", + "dist", + "halfnormal", + "half-normal", + "half normal", + "univariate", + "continuous" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/factory.js new file mode 100644 index 000000000000..2c41e9b7cc3b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/factory.js @@ -0,0 +1,93 @@ +/** +* @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 constantFunction = require( '@stdlib/utils/constant-function' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var exp = require( '@stdlib/math/base/special/exp' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var PI = require( '@stdlib/constants/float64/pi' ); +var SQRT2 = require( '@stdlib/constants/float64/sqrt-two' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); + + +// MAIN // + +/** +* Returns a function for evaluating the probability density function (PDF) for a half-normal distribution. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {Function} function to evaluate the probability density function +* +* @example +* var pdf = factory( 2.0 ); +* var y = pdf( 1.0 ); +* // returns 0.3520653267642996 +* +* y = pdf( 0.0 ); +* // returns 0.3989422804014327 +*/ +function factory( sigma ) { + var s2; + var A; + if ( + isnan( sigma ) || + sigma < 0.0 + ) { + return constantFunction( NaN ); + } + if ( sigma === 0.0 ) { + return pdf; + } + s2 = pow( sigma, 2.0 ); + A = SQRT2 / ( sigma * sqrt( PI ) ); + return pdf; + + /** + * Evaluates the probability density function (PDF) for a half-normal distribution. + * + * @private + * @param {number} x - input value + * @returns {number} evaluated probability density function + * + * @example + * var y = pdf( 2.0 ); + * // returns + */ + function pdf( x ) { + if ( isnan( x ) ) { + return NaN; + } + if ( x < 0.0 ) { + return 0.0; + } + if ( sigma === 0.0 ) { + return ( x === 0.0 ) ? PINF : 0.0; + } + return A * exp( -pow( x, 2.0 ) / ( 2.0 * s2 ) ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/index.js new file mode 100644 index 000000000000..de88b5c543ce --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/index.js @@ -0,0 +1,51 @@ +/** +* @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'; + +/** +* Half-normal distribution probability density function (PDF). +* +* @module @stdlib/stats/base/dists/halfnormal/pdf +* +* @example +* var pdf = require( '@stdlib/stats/base/dists/halfnormal/pdf' ); +* +* var y = pdf( 2.0, 1.0 ); +* // returns 0.10798193302637613 +* +* var myPDF = pdf.factory( 2.0 ); +* y = myPDF( 1.0 ); +* // returns 0.3520653267642996 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/main.js new file mode 100644 index 000000000000..0f3d3bc1fb1c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/lib/main.js @@ -0,0 +1,98 @@ +/** +* @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 exp = require( '@stdlib/math/base/special/exp' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var PI = require( '@stdlib/constants/float64/pi' ); +var SQRT2 = require( '@stdlib/constants/float64/sqrt-two' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Evaluates the probability density function (PDF) for a half-normal distribution with scale parameter `sigma` at a value `x`. +* +* @param {number} x - input value +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} evaluated probability density function +* +* @example +* var y = pdf( 2.0, 1.0 ); +* // returns 0.10798193302637613 +* +* @example +* var y = pdf( -1.0, 2.0 ); +* // returns 0.0 +* +* @example +* var y = pdf( 0.0, 1.0 ); +* // returns 0.7978845608028654 +* +* @example +* var y = pdf( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = pdf( 0.0, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = pdf( 2.0, -1.0 ); +* // returns NaN +* +* @example +* var y = pdf( 2.0, 0.0 ); +* // returns 0.0 +* +* @example +* var y = pdf( 0.0, 0.0 ); +* // returns Infinity +*/ +function pdf( x, sigma ) { + var s2; + var A; + if ( + isnan( x ) || + isnan( sigma ) || + sigma < 0.0 + ) { + return NaN; + } + if ( x < 0.0 ) { + return 0.0; + } + if ( sigma === 0.0 ) { + return ( x === 0.0 ) ? PINF : 0.0; + } + s2 = pow( sigma, 2.0 ); + A = SQRT2 / ( sigma * sqrt( PI ) ); + return A * exp( -pow( x, 2.0 ) / ( 2.0 * s2 ) ); +} + + +// EXPORTS // + +module.exports = pdf; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/package.json new file mode 100644 index 000000000000..ded71e3a6195 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/pdf/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/pdf", + "version": "0.0.0", + "description": "Half-normal distribution probability density function (PDF).", + "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", + "continuous", + "probability", + "pdf", + "halfnormal", + "half-normal", + "half normal", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js new file mode 100644 index 000000000000..0fc7b9e55a19 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js @@ -0,0 +1,91 @@ +/** +* @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 constantFunction = require( '@stdlib/utils/constant-function' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var erfinv = require( '@stdlib/math/base/special/erfinv' ); + + +// MAIN // + +/** +* Returns a function for evaluating the quantile function for a half-normal distribution. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {Function} function to evaluate the quantile function +* +* @example +* var quantile = factory( 2.0 ); +* var y = quantile( 0.5 ); +* // returns 1.3489795003921634 +* +* y = quantile( 0.9 ); +* // returns 3.289707253902946 +*/ +function factory( sigma ) { + var factor; + if ( + isnan( sigma ) || + sigma < 0.0 + ) { + return constantFunction( NaN ); + } + if ( sigma === 0.0 ) { + return constantFunction( 0.0 ); + } + factor = sigma * sqrt( 2.0 ); + return quantile; + + /** + * Evaluates the quantile function for a half-normal distribution. + * + * @private + * @param {Probability} p - input probability + * @returns {number} evaluated quantile function + * + * @example + * var y = quantile( 0.5 ); + * // returns + */ + function quantile( p ) { + if ( + isnan( p ) || + p < 0.0 || + p > 1.0 + ) { + return NaN; + } + if ( p === 0.0 ) { + return 0.0; + } + if ( p === 1.0 ) { + return Infinity; + } + return factor * erfinv( p ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js new file mode 100644 index 000000000000..2deaa792c9f2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js @@ -0,0 +1,51 @@ +/** +* @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'; + +/** +* Half-normal distribution quantile function. +* +* @module @stdlib/stats/base/dists/halfnormal/quantile +* +* @example +* var quantile = require( '@stdlib/stats/base/dists/halfnormal/quantile' ); +* +* var y = quantile( 0.5, 1.0 ); +* // returns 0.6744897501960817 +* +* var myQuantile = quantile.factory( 2.0 ); +* y = myQuantile( 0.5 ); +* // returns 1.3489795003921634 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js new file mode 100644 index 000000000000..7bd8e170f94b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js @@ -0,0 +1,92 @@ +/** +* @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 erfinv = require( '@stdlib/math/base/special/erfinv' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Evaluates the quantile function for a half-normal distribution with scale parameter `sigma` at a probability `p`. +* +* @param {Probability} p - input probability +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} evaluated quantile function +* +* @example +* var y = quantile( 0.5, 1.0 ); +* // returns 0.6744897501960817 +* +* @example +* var y = quantile( 0.9, 2.0 ); +* // returns 3.289707253902946 +* +* @example +* var y = quantile( 0.0, 1.0 ); +* // returns 0.0 +* +* @example +* var y = quantile( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( 0.5, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = quantile( 0.5, -1.0 ); +* // returns NaN +* +* @example +* // Invalid probability: +* var y = quantile( 1.5, 1.0 ); +* // returns NaN +*/ +function quantile( p, sigma ) { + if ( + isnan( p ) || + isnan( sigma ) || + sigma < 0.0 || + p < 0.0 || + p > 1.0 + ) { + return NaN; + } + if ( sigma === 0.0 ) { + return 0.0; + } + if ( p === 0.0 ) { + return 0.0; + } + if ( p === 1.0 ) { + return Infinity; + } + return sigma * sqrt( 2.0 ) * erfinv( p ); +} + + +// EXPORTS // + +module.exports = quantile; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json new file mode 100644 index 000000000000..8081d01e6b08 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/quantile", + "version": "0.0.0", + "description": "Half-normal distribution quantile function.", + "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", + "continuous", + "probability", + "quantile", + "halfnormal", + "half-normal", + "half normal", + "univariate", + "inverse" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/index.js new file mode 100644 index 000000000000..120595390934 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/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'; + +/** +* Half-normal distribution skewness. +* +* @module @stdlib/stats/base/dists/halfnormal/skewness +* +* @example +* var skewness = require( '@stdlib/stats/base/dists/halfnormal/skewness' ); +* +* var y = skewness( 1.0 ); +* // returns ~0.995 +* +* y = skewness( 4.0 ); +* // returns ~0.995 +*/ + +// MODULES // + +var skewness = require( './main.js' ); + + +// EXPORTS // + +module.exports = skewness; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/main.js new file mode 100644 index 000000000000..3c40bb366ee4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/lib/main.js @@ -0,0 +1,64 @@ +/** +* @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' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var PI = require( '@stdlib/constants/float64/pi' ); +var SQRT2 = require( '@stdlib/constants/float64/sqrt-two' ); + + +// MAIN // + +/** +* Returns the skewness of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {number} skewness +* +* @example +* var y = skewness( 1.0 ); +* // returns ~0.995 +* +* @example +* var y = skewness( 4.0 ); +* // returns ~0.995 +* +* @example +* var y = skewness( NaN ); +* // returns NaN +* +* @example +* var y = skewness( -1.0 ); +* // returns NaN +*/ +function skewness( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + // Skewness = (sqrt(2) * (4 - PI)) / (PI - 2)^(3/2) + return ( SQRT2 * ( 4.0 - PI ) ) / pow( PI - 2.0, 1.5 ); +} + + +// EXPORTS // + +module.exports = skewness; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/package.json new file mode 100644 index 000000000000..5b2e04c27485 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/skewness/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/skewness", + "version": "0.0.0", + "description": "Half-normal distribution skewness.", + "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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "skewness", + "skew", + "asymmetry", + "shape" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/index.js new file mode 100644 index 000000000000..94b873b89ba6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/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'; + +/** +* Half-normal distribution standard deviation. +* +* @module @stdlib/stats/base/dists/halfnormal/stdev +* +* @example +* var stdev = require( '@stdlib/stats/base/dists/halfnormal/stdev' ); +* +* var y = stdev( 1.0 ); +* // returns 0.6028102749890869 +* +* y = stdev( 4.0 ); +* // returns 2.4112410999563476 +*/ + +// MODULES // + +var stdev = require( './main.js' ); + + +// EXPORTS // + +module.exports = stdev; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/main.js new file mode 100644 index 000000000000..1a5037387f0f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var PI = require( '@stdlib/constants/float64/pi' ); + + +// MAIN // + +/** +* Returns the standard deviation of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {PositiveNumber} standard deviation +* +* @example +* var y = stdev( 1.0 ); +* // returns 0.6028102749890869 +* +* @example +* var y = stdev( 4.0 ); +* // returns 2.4112410999563476 +* +* @example +* var y = stdev( NaN ); +* // returns NaN +* +* @example +* var y = stdev( -1.0 ); +* // returns NaN +*/ +function stdev( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + return sigma * sqrt( 1.0 - ( 2.0 / PI ) ); +} + + +// EXPORTS // + +module.exports = stdev; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/package.json new file mode 100644 index 000000000000..7cfa98fdb968 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/stdev/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/stdev", + "version": "0.0.0", + "description": "Half-normal distribution standard deviation.", + "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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "stdev", + "standard deviation", + "dispersion", + "spread", + "sigma" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/index.js new file mode 100644 index 000000000000..8d684e909d09 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/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'; + +/** +* Half-normal distribution variance. +* +* @module @stdlib/stats/base/dists/halfnormal/variance +* +* @example +* var variance = require( '@stdlib/stats/base/dists/halfnormal/variance' ); +* +* var y = variance( 1.0 ); +* // returns ~0.363 +* +* y = variance( 4.0 ); +* // returns ~5.814 +*/ + +// MODULES // + +var variance = require( './main.js' ); + + +// EXPORTS // + +module.exports = variance; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/main.js new file mode 100644 index 000000000000..f03a3ad1e965 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var PI = require( '@stdlib/constants/float64/pi' ); + + +// MAIN // + +/** +* Returns the variance of a half-normal distribution with scale parameter `sigma`. +* +* @param {PositiveNumber} sigma - scale parameter +* @returns {PositiveNumber} variance +* +* @example +* var y = variance( 1.0 ); +* // returns ~0.363 +* +* @example +* var y = variance( 4.0 ); +* // returns ~5.814 +* +* @example +* var y = variance( NaN ); +* // returns NaN +* +* @example +* var y = variance( -1.0 ); +* // returns NaN +*/ +function variance( sigma ) { + if ( isnan( sigma ) || sigma < 0.0 ) { + return NaN; + } + return pow( sigma, 2.0 ) * ( 1.0 - ( 2.0 / PI ) ); +} + + +// EXPORTS // + +module.exports = variance; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/package.json new file mode 100644 index 000000000000..6a1b5497c997 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/variance/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/variance", + "version": "0.0.0", + "description": "Half-normal distribution variance.", + "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", + "continuous", + "halfnormal", + "half-normal", + "univariate", + "variance", + "variability", + "dispersion", + "spread" + ] +}