feat: add stats/incr/nanwmean#13609
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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- 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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- 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: 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: 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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- 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: 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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- 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: 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
---
---
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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- 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: 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_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- 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:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown_pkg_readmes
status: na
- task: lint_markdown_docs
status: na
- task: lint_markdown
status: na
- 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: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: missing_dependencies
- 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
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
stats/incr/nanwmeanstats/incr/nanwmean
|
/stdlib update-copyright-years |
Neerajpathak07
left a comment
There was a problem hiding this comment.
@Arjan-P Thanks for the PR!! Left out a few comments. Commonly we want to prevent a straight away copy-paste between subsequent packages and think a bit more on what is the true intention and nature of nanwmean being added here.
| * | ||
| * ## Notes | ||
| * | ||
| * - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations. |
There was a problem hiding this comment.
Copied from incr/wmean, it's the opposite of what nanwmean does (NaN is ignored). Sibling incr/nanewmean omits this note.
| type accumulator = ( x?: number, w?: number ) => number | null; | ||
|
|
||
| /** | ||
| * Returns an accumulator function which incrementally computes a weighted arithmetic mean. |
There was a problem hiding this comment.
Should read "... weighted arithmetic mean, ignoring NaN values." to match nanewmean and the module description.
| * limitations under the License. | ||
| */ | ||
|
|
||
| import incrwmean = require( './index' ); |
There was a problem hiding this comment.
incorrect package name. Copy paste error from incrwmean
There was a problem hiding this comment.
Should be updated below as well!!!
| // MAIN // | ||
|
|
||
| /** | ||
| * Returns an accumulator function which incrementally computes a weighted arithmetic mean, ignoring `NaN` parameters. |
There was a problem hiding this comment.
package.json, repl.txt, and sibling packages say "ignoring NaN values". Let's Align here on "values".
| /** | ||
| * Returns an accumulator function which incrementally computes a weighted arithmetic mean, ignoring `NaN` parameters. | ||
| * | ||
| * ## Method |
There was a problem hiding this comment.
The full TeX derivation is duplicated from incr/wmean, which this package merely wraps it will drift out of sync. incr/nanewmean keeps a one-line description; recommend trimming to that plus a NaN args are ignored note.
| if ( isnan( x ) || isnan( w ) ) { | ||
| return acc(); |
There was a problem hiding this comment.
| if ( isnan( x ) || isnan( w ) ) { | |
| return acc(); | |
| if ( arguments.length < 2 || isnan( x ) || isnan( w ) ) { | |
| return acc(); |
Calling acc( 2.0 ) with no weight leaves w === undefined, isnan( undefined ) is false, so this guard is bypassed and acc( 2.0, undefined ) corrupts wsum/mu to NaN for every subsequent call unrecoverable, and exactly what a nan-accumulator should prevent.
| w = data[ i ].w; | ||
| expected = data[ i ].mean; | ||
| actual = acc( x, w ); | ||
| t.strictEqual( isAlmostSameValue( actual, expected, 150.0 ), true, 'within tolerance. x: ' + x + '. w: ' + w + '. Value: ' + actual + '. Expected: ' + expected + '.' ); |
There was a problem hiding this comment.
A bit high value for ULP Diff here. Consider a relative-error tolerance (as other incr/* tests use) or fixtures bounded away from zero.
|
My bad, will be more mindful going forth. I think the package is also missing a README.md. Thank you for the feedback, will address these as soon as possible. |
Description
This pull request:
NaNvalues instats/incr/nanwmeanRelated Issues
This pull request has the following related issues:
stats/incr/nanwmean#5628Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
Generated package.json, repl.txt from gemini
@stdlib-js/reviewers