Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fad77ea
fix: remove extra bracket spacing in test.isamax.js (#8357)
anujmishra03 Nov 3, 2025
98ac26e
trigger CI
anujmishra03 Nov 3, 2025
338d5dc
style: remove whitespace
kgryte Nov 3, 2025
5b59907
fix: address off-by-one bug
kgryte Nov 1, 2025
49f8acd
fix: address off-by-one bug
kgryte Nov 1, 2025
d0f2211
fix: address off-by-one bug
kgryte Nov 1, 2025
f997591
fix: address off-by-one bug
kgryte Nov 1, 2025
b15a5f0
feat: add `ndarray/base/some`
headlessNode Nov 1, 2025
ff2b861
test: fix descriptions
kgryte Nov 2, 2025
15ec4fb
docs: update examples
kgryte Nov 2, 2025
6943caa
docs: remove incorrect comment
kgryte Nov 2, 2025
3a25df5
build: account for additional declaration patterns
kgryte Nov 2, 2025
93a6944
feat: add `blas/ext/to-sortedhp`
headlessNode Nov 2, 2025
92a2de1
docs: update Markdown stdlib package URLs
stdlib-bot Nov 3, 2025
0a9b8a3
chore: add structured package data for `math/base/special/sech`
manvith2003 Nov 3, 2025
3020896
chore: add structured package data for `math/base/special/signum`
manvith2003 Nov 3, 2025
b62f52e
chore: add structured package data for `math/base/special/signumf`
manvith2003 Nov 3, 2025
45e7fe9
chore: add structured package data for `math/base/special/secd`
manvith2003 Nov 3, 2025
be9b22b
chore: add structured package data for `math/base/special/secdf`
manvith2003 Nov 3, 2025
1d62fb5
chore: add structured package data for `math/base/special/secf`
manvith2003 Nov 3, 2025
5c77273
chore: add structured package data for `math/base/special/hacoversin`
nakul-krishnakumar Nov 3, 2025
92d04cb
chore: add structured package data for `math/base/special/haversin`
nakul-krishnakumar Nov 3, 2025
52ce4b3
chore: add structured package data for `math/base/special/factoriallnf`
nakul-krishnakumar Nov 3, 2025
d9f9dd2
chore: add structured package data for `math/base/special/versin`
nakul-krishnakumar Nov 3, 2025
db3a42f
chore: add structured package data for `math/base/special/cceilf`
nakul-krishnakumar Nov 3, 2025
0e7e207
chore: add structured package data for `math/base/special/round`
Orthodox-64 Nov 3, 2025
6699064
chore: add structured package data for `math/base/special/round2`
Orthodox-64 Nov 3, 2025
491757b
chore: add structured package data for `math/base/special/floor`
Payal-Goswami Nov 3, 2025
8c155ff
chore: fix C lint errors
GeoDaoyu Nov 3, 2025
c222218
feat: update math scaffold databases
stdlib-bot Nov 3, 2025
f0d9394
chore: fix EditorConfig lint errors
sujalc879 Nov 3, 2025
32a5730
feat: add `ndarray/concat`
headlessNode Nov 3, 2025
cba4e23
refactor: pass ndarray view to internal function
kgryte Nov 3, 2025
bbda71d
fix(stats/halfnormal): correct PDF implementation and adjust test tol…
anujmishra03 Nov 6, 2025
f5af2f3
feat(stats/halfnormal): add PDF implementation and tests
anujmishra03 Nov 6, 2025
34be4cd
docs(stats/halfnormal): fix require path in README example
anujmishra03 Nov 6, 2025
1af2a64
chore(stats/halfnormal): add missing license headers
anujmishra03 Nov 6, 2025
e70b0bc
chore: resolve conflict in unary.json
anujmishra03 Nov 8, 2025
30415c2
chore: fix license headers and update halfnormal PDF implementation
anujmishra03 Nov 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lib/node_modules/@stdlib/stats/base/dists/halfnormal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
@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.
-->

# Half-Normal Distribution

> Half-normal distribution.

<section class="intro">

The half-normal distribution is a continuous probability distribution whose values are the absolute values of a normally distributed random variable with mean zero.

</section>

<section class="usage">

## Usage

```javascript
var pdf = require( '@stdlib/stats/base/dists/halfnormal' ).pdf;

var y = pdf( 1.0, 1.0 );
console.log( y );
25 changes: 25 additions & 0 deletions lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**

Check failure on line 1 in lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

JSDoc comment for main export is missing `@module @stdlib/stats/base/dists/halfnormal` tag
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var pdf = require('./pdf.js');

Check failure on line 21 in lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space before the closing parenthesis in require calls

Check failure on line 21 in lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

There should be exactly one space after the opening parenthesis in require calls

module.exports = {
pdf: pdf

Check failure on line 24 in lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unquoted property 'pdf' found

Check failure on line 24 in lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Expected indentation of 1 tab but found 2 spaces
};
37 changes: 37 additions & 0 deletions lib/node_modules/@stdlib/stats/base/dists/halfnormal/lib/pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var 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');
const TWO = 2.0;

function pdf(x, sigma) {
if (sigma <= 0.0) {
return NaN;
}
if (x < 0.0) {
return 0.0;
}
return sqrt(TWO / (PI * pow(sigma, 2))) * exp(-pow(x, 2) / (TWO * pow(sigma, 2)));
}

module.exports = pdf;
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/



'use strict';

// MODULES //
var tape = require('tape');
var pdf = require('../lib/pdf.js');
var isnan = require('@stdlib/math/base/assert/is-nan');

// TESTS //
tape('main export is a function', function(t) {
t.equal(typeof pdf, 'function', 'main export is a function');
t.end();
});

tape('returns NaN if sigma <= 0', function(t) {
t.equal(isnan(pdf(1.0, 0.0)), true, 'sigma = 0 returns NaN');
t.equal(isnan(pdf(1.0, -1.0)), true, 'negative sigma returns NaN');
t.end();
});

tape('pdf is zero for x < 0', function(t) {
t.equal(pdf(-0.5, 1.0), 0.0, 'x < 0 returns 0');
t.end();
});

tape('pdf evaluates half-normal distribution for valid inputs', function(t) {
var sigma = 1.0;
var xs = [0.0, 0.5, 1.0, 2.0];
for (var i = 0; i < xs.length; i++) {
var v = pdf(xs[i], sigma);
t.ok(v >= 0, 'pdf(' + xs[i] + ',1.0) = ' + v);
}
t.end();
});

Loading