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

Progresses #9416.

Description

This pull request adds and validates the half-normal logpdf implementation, including C, JavaScript, and TypeScript bindings, and corrects documentation examples to match the mathematically correct half-normal distribution. The implementation and reference values are aligned with Julia’s Truncated(Normal(0, σ), 0, Inf) ground-truth model.

Related Issues

This pull request has the following related issues:

Questions

No.

Other

The numerical reference values were verified against Julia’s Distributions.jl implementation of a half-normal distribution via a truncated normal model. Documentation examples were updated to reflect these correct reference values.

Checklist

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 AI assistance to verify the mathematical formula for the half-normal log-PDF and to confirm expected numerical values using Julia as a reference.


@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 12, 2026
@Om-A-osc Om-A-osc changed the title feat: add implementation for halfnormal/logpdf feat: add implementation for stats/base/dists/halfnormal/logpdf Jan 12, 2026
@Om-A-osc Om-A-osc changed the title feat: add implementation for stats/base/dists/halfnormal/logpdf feat: add implementation for stats/base/dists/halfnormal/logpdf Jan 12, 2026
@Planeshifter Planeshifter self-requested a review January 12, 2026 19:55
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 your first contribution to stdlib!

x = random_uniform( 0.0, 10.0 );
sigma = random_uniform( 0.0, 10.0 );
y = stdlib_base_dists_halfnormal_logpdf( x, sigma );
printf( "x: %0.4f, σ: %0.4f, ln(f(x;σ)): %0.4f\n", x, sigma, y );
Copy link
Member

@Planeshifter Planeshifter Jan 12, 2026

Choose a reason for hiding this comment

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

For consistency with other stdlib C examples, we should use %lf for double values instead of %0.4f.

Suggested change
printf( "x: %0.4f, σ: %0.4f, ln(f(x;σ)): %0.4f\n", x, sigma, y );
printf( "x: %lf, σ: %lf, ln(f(x;σ)): %lf\n", x, sigma, y );

The README.md should be updated accordingly.

@stdlib-bot
Copy link
Contributor

Coverage Report

No coverage information available.

---
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: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - 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: missing_dependencies
  - 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

Hello @Planeshifter, I’ve made the requested changes and addressed the review comments. Please have a look when you have a moment. Thank you!

---
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: passed
  - 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: 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
---
@Om-A-osc Om-A-osc requested a review from Planeshifter January 14, 2026 14:58
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 Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants