Skip to content

Conversation

@Om-A-osc
Copy link


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: passed
  • task: lint_javascript_src status: passed
  • task: lint_javascript_cli status: na
  • task: lint_javascript_examples status: passed
  • task: lint_javascript_tests status: passed
  • task: lint_javascript_benchmarks status: passed
  • task: lint_python status: na
  • task: lint_r status: na
  • task: lint_c_src status: missing_dependencies
  • task: lint_c_examples status: missing_dependencies
  • task: lint_c_benchmarks status: missing_dependencies
  • task: lint_c_tests_fixtures status: na
  • task: lint_shell status: na
  • task: lint_typescript_declarations status: passed
  • task: lint_typescript_tests status: passed
  • task: lint_license_headers status: passed ---

Resolves #9416.

Description

What is the purpose of this pull request?

This pull request:

  • Adds an implementation of excess kurtosis for the half-normal distribution.
  • Uses the closed-form analytic expression , which is independent of the scale parameter.
  • Introduces corresponding fixtures, documentation, tests, and REPL examples.
  • Ensures consistency with existing stdlib distribution implementations and linting rules.

Related Issues

Does this pull request have any related issues?

This pull request progresses the following related issue:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

I used llm , wikipedia and other mathematical websites in a limited capacity to verify the mathematical formula for half-normal excess kurtosis and to cross-check references. All code, tests, and documentation were authored manually.


@stdlib-js/reviewers

---
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: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. labels Jan 15, 2026
Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this PR!

Comment on lines 21 to 24
// VARIABLES //

var PI = require( '@stdlib/constants/float64/pi' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section header should be // MODULES // since it contains require statements. The // VARIABLES // section is for computed constants and other variable declarations.

Suggested change
// VARIABLES //
var PI = require( '@stdlib/constants/float64/pi' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
// MODULES //
var PI = require( '@stdlib/constants/float64/pi' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );

) {
return 0.0 / 0.0; // NaN
}
return ( 8.0 * ( STDLIB_CONSTANT_FLOAT64_PI - 3.0 ) ) / ( ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) *( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before the multiplication operator. Let's match the stdlib C style guide.

Suggested change
return ( 8.0 * ( STDLIB_CONSTANT_FLOAT64_PI - 3.0 ) ) / ( ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) *( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) );
return ( 8.0 * ( STDLIB_CONSTANT_FLOAT64_PI - 3.0 ) ) / ( ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) * ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) );

Comment on lines 37 to 41
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
// Generate valid scale parameters:
sigma = ( randu() * 10.0 ) + 0.1;
y = kurtosis( sigma );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The random data generation should happen outside the timing loop. Per latest stdlib benchmark conventions, pre-generate values before b.tic() and cycle through them using modulo indexing.

Comment on lines 17 to 23
"directories": {
"benchmark": "./benchmark",
"doc": "./docs",
"example": "./examples",
"lib": "./lib",
"test": "./test"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this package has a C implementation with a .gyp file, we need to add "gypfile": true and include the include and src directories. See @stdlib/stats/base/dists/levy/pdf/package.json for reference.

The directories section should look like:

"directories": {
  "benchmark": "./benchmark",
  "doc": "./docs",
  "example": "./examples",
  "include": "./include",
  "lib": "./lib",
  "src": "./src",
  "test": "./test"
}

And add "gypfile": true after line 16.

sigma = data.sigma;
for ( i = 0; i < sigma.length; i++ ) {
y = kurtosis( sigma[i] );
if ( expected[i] !== null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before the closing parenthesis to match stdlib style.

Suggested change
if ( expected[i] !== null) {
if ( expected[i] !== null ) {

for ( i = 0; i < 10; i++ ) {
sigma = randu() * 20.0;
y = kurtosis( sigma );
console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript's console.log doesn't interpret %lf as a format specifier - it just prints it literally. Use %d for numbers instead.

Suggested change
console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y );
console.log( 'σ: %d, Kurt(σ): %d', sigma, y );

for ( i = 0; i < 10; i++ ) {
sigma = randu() * 20.0;
y = kurtosis( sigma );
console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here - %lf won't work as a format specifier in JavaScript. Use %d instead.

Suggested change
console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y );
console.log( 'σ: %d, Kurt(σ): %d', sigma, y );

}
b.pass( 'benchmark finished' );
b.end();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package is missing benchmark/benchmark.native.js which is needed for benchmarking the native addon. See @stdlib/stats/base/dists/levy/pdf/benchmark/benchmark.native.js for a reference implementation.

@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/halfnormal/kurtosis $\color{green}153/153$
$\color{green}+100.00%$
$\color{green}7/7$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}153/153$
$\color{green}+100.00%$

The above coverage report was generated for the changes in this PR.

@stdlib-bot stdlib-bot added the Potential Duplicate There might be another pull request resolving the same issue. label Jan 16, 2026
@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jan 16, 2026
---
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: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - 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
---
@Om-A-osc
Copy link
Author

@Planeshifter I’ve addressed the requested changes. I’d appreciate it if you could take another look when convenient thanks again for your help.

@Om-A-osc Om-A-osc requested a review from Planeshifter January 16, 2026 18:13
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 16, 2026
---
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: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: missing_dependencies
  - 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
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Changes Pull request which needs changes before being merged. Needs Review A pull request which needs code review. Potential Duplicate There might be another pull request resolving the same issue. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Tracking issue for complete implementation of @stdlib/stats/base/dists/halfnormal package

3 participants