feat: add stats/incr/wvariance incremental weighted variance#9958
feat: add stats/incr/wvariance incremental weighted variance#9958Om-A-osc wants to merge 4 commits intostdlib-js:developfrom
stats/incr/wvariance incremental weighted variance#9958Conversation
---
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: passed
- 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. |
|
@Planeshifter Please review this. |
---
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: passed
- 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:
- 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: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: passed
- 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
---
|
@kgryte Hey I did the requested changes. |
| var incrwvariance = require( './../lib' ); | ||
|
|
||
|
|
||
| // TESTS // |
There was a problem hiding this comment.
Missing tests for invalid input types. All incr/* packages test that non-numeric inputs (strings, booleans, null, arrays, objects, functions) are handled. See incr/mpe or incr/wmean test files for the expected pattern.
There was a problem hiding this comment.
Hi @Planeshifter,
I looked into this before implementing and double-checked again now. The two-argument accumulator packages you mentioned incr/wmean and incr/mpe do not perform any type checks on their accumulator inputs beyond NaN handling.
incr/wmean (lib/main.js) has no isNumber, no typeof checks, and no non-numeric input tests in its test file. The accumulator directly computes:
wsum += w;
mu += (w/wsum) * (x - mu);without any input validation.
incr/mpe follows the same pattern: no type validation on accumulator arguments and no non-numeric input tests.
incr/rss also follows the same pattern with no type checks on accumulator inputs.
The isNumber + throw TypeError pattern that exists in packages like incr/variance and incr/stdev is used to validate the factory function’s configuration arguments (e.g., incrvariance(mean) validates the optional known-mean parameter), not the data values passed to the accumulator on each call.
Since incrwvariance() takes no factory arguments, there's nothing to validate at construction time. The current implementation already includes isnan checks on the accumulator inputs (x, w) and an arguments.length !== 2 guard, which is consistent with and slightly more defensive than the existing two-argument accumulator packages.
Happy to add non-numeric type checks if that's something we want to introduce as a new convention, but wanted to flag that existing packages don't currently follow that pattern.
---
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: passed
- task: lint_javascript_src
status: passed
- 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:
Resolves #46.
Description
This pull request:
The incremental update follows the weighted Welford formulation:
Related Issues
This pull request has the following related issues:
stats/incr/wvariance#46Questions
No.
Other
Checklist
AI Assistance
Disclosure
No AI assistance was used in the implementation, tests, or documentation.
@stdlib-js/reviewers