-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add implementation for stats/base/dists/halfnormal/logpdf
#9708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
---
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
---
stats/base/dists/halfnormal/logpdf
Planeshifter
left a comment
There was a problem hiding this 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 ); |
There was a problem hiding this comment.
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.
| 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.
Coverage ReportNo 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
---
|
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
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
status: passed
status: passed
status: passed
status: passed
status: passed
status: passed
status: na
status: passed
status: passed
status: passed
status: na
status: na
status: missing_dependencies
status: missing_dependencies
status: missing_dependencies
status: na
status: na
status: passed
status: passed
status: passed
Progresses #9416.
Description
This pull request adds and validates the half-normal
logpdfimplementation, 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’sTruncated(Normal(0, σ), 0, Inf)ground-truth model.Related Issues
This pull request has the following related issues:
@stdlib/stats/base/dists/halfnormalpackage #9416Questions
No.
Other
The numerical reference values were verified against Julia’s
Distributions.jlimplementation of a half-normal distribution via a truncated normal model. Documentation examples were updated to reflect these correct reference values.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
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