-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: initial implementation of stats/base/dists/halfnormal/cdf
#9429
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: 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: passed
- task: lint_license_headers
status: passed
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
stats/base/dists/halfnormal/cdf
| "@stdlib/math/base/assert/is-nan": "^0.2.2", | ||
| "@stdlib/math/base/special/erf": "^0.2.2", | ||
| "@stdlib/math/base/special/sqrt": "^0.2.2", | ||
| "@stdlib/stats/base/dists/degenerate/cdf": "^0.2.2", | ||
| "@stdlib/utils/constant-function": "^0.2.2", | ||
| "@stdlib/utils/define-nonenumerable-read-only-property": "^0.2.2" |
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.
| "@stdlib/math/base/assert/is-nan": "^0.2.2", | |
| "@stdlib/math/base/special/erf": "^0.2.2", | |
| "@stdlib/math/base/special/sqrt": "^0.2.2", | |
| "@stdlib/stats/base/dists/degenerate/cdf": "^0.2.2", | |
| "@stdlib/utils/constant-function": "^0.2.2", | |
| "@stdlib/utils/define-nonenumerable-read-only-property": "^0.2.2" |
| t.end(); | ||
| }); | ||
|
|
||
| tape('if provided `x < mu`, the function returns `0`', function test(t) { |
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.
| tape('if provided `x < mu`, the function returns `0`', function test(t) { | |
| tape( 'if provided `x < mu`, the function returns `0`', function test( t ) { |
| t.equal(y, expected[i], 'x: ' + x[i] + ', mu: ' + mu[i] + ', sigma: ' + sigma[i] + ', y: ' + y + ', expected: ' + expected[i]); | ||
| } else { | ||
| del = abs(y - expected[i]); | ||
| t.ok(del <= 1e-14, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. Delt: ' + del); |
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.
| t.ok(del <= 1e-14, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. Delt: ' + del); | |
| t.ok(del <= 1e-14, 'within tolerance. x: ' + x[i] + '. y: ' + y + '. E: ' + expected[i] + '. Delt: ' + del); |
Use assert/is-almost-same-value with an appropriate maxULPs argument.
| * | ||
| * @example | ||
| * var y = cdf( 2.0, 0.0, 1.0 ); | ||
| * // returns 0.9544997361036416 |
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.
| * // returns 0.9544997361036416 | |
| * // returns ~0.9545 |
|
|
||
| ```javascript | ||
| var y = cdf( 2.0, 0.0, 1.0 ); | ||
| // returns 0.9544997361036416 |
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.
| // returns 0.9544997361036416 | |
| // returns ~0.9545 |
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: na
status: na
status: na
status: na
status: na
status: passed
status: passed
status: passed
Progresses #9416
Description
This pull request:
@stdlib/stats/base/dists/halfnormal/cdfpackage with complete functionality including:Related Issues
This pull request has the following related issues:
Questions
No.
Other
Implementation Notes:
The half-normal distribution CDF is implemented using the error function (erf):
where μ is the location parameter and σ is the scale parameter.
Package Structure:
The implementation closely mirrors the structure of
@stdlib/stats/base/dists/normal/cdfto ensure consistency across the stdlib codebase:lib/main.js- Main CDF implementationlib/factory.js- Factory function for partial applicationlib/index.js- Package exportstest/test.cdf.js- Comprehensive tests for the main functiontest/test.factory.js- Tests for the factory functiontest/test.js- Basic module testsexamples/index.js- Usage examplesbenchmark/benchmark.js- Performance benchmarksdocs/types/index.d.ts- TypeScript definitionsdocs/types/test.ts- TypeScript definition testsdocs/repl.txt- REPL documentationtest/fixtures/julia/- Test fixture generation scriptsChecklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
The tests and documentation were primarily authored by Claude Code, but the research and understanding of the half-normal distribution were done by me, and the CDF function's code implementation was entirely authored and reviewed by me.
@stdlib-js/reviewers