-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: implement entropy for hypergeometric distribution #9395
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
---
|
/stdlib update-copyright-years |
| * var h = entropy( 10, 5, 12 ); | ||
| * // returns NaN | ||
| */ | ||
| function entropy(N, K, n) { |
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.
You should update your use of whitespace here and below in order to be consistent within this package and with the rest of stdlib.
| function entropy(N, K, n) { | |
| function entropy( N, K, n ) { |
| max = (n < K) ? n : K; | ||
|
|
||
| H = 0.0; | ||
| for (k = min; k <= max; k++) { |
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.
This approach seems to match SciPy: https://github.com/scipy/scipy/blob/v1.16.2/scipy/stats/_discrete_distns.py#L704. For more robust summation, we could consider an accumulator which isn't ordinary recursive summation (e.g., https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/sum).
|
@24archit You'll need to resolve CI failures before this PR can move forward. Thanks! |
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Description
This pull request:
Related Issues
This pull request has the following related issues:
Questions
No.
Other
Local linting passed for JavaScript and Markdown files. Cppcheck was not run locally due to missing dependencies but the code compiles successfully.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers