-
-
Notifications
You must be signed in to change notification settings - Fork 813
feat: add stats/incr/nanmmean
#6185
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?
feat: add stats/incr/nanmmean
#6185
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 ---
Hello! Thank you for your contribution to stdlib. We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
||
#### incrnanmmean( window ) | ||
|
||
Returns an accumulator `function` which incrementally computes a moving [arithmetic mean][arithmetic-mean]. The `window` parameter defines the number of values over which to compute the moving mean. |
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 an accumulator `function` which incrementally computes a moving [arithmetic mean][arithmetic-mean]. The `window` parameter defines the number of values over which to compute the moving mean. | |
Returns an accumulator function which incrementally computes a moving [arithmetic mean][arithmetic-mean], ignoring `NaN` values.. The `window` parameter defines the number of values over which to compute the moving mean. |
var randu = require( '@stdlib/random/base/randu' ); | ||
var incrnanmmean = require( '@stdlib/stats/incr/nanmmean' ); | ||
|
||
var accumulator; | ||
var v; | ||
var i; | ||
|
||
// Initialize an accumulator: | ||
accumulator = incrnanmmean( 5 ); | ||
|
||
// For each simulated datum, update the moving mean... | ||
for ( i = 0; i < 100; i++ ) { | ||
if ( randu() < 0.2 ) { | ||
v = NaN; | ||
} else { | ||
v = randu() * 100.0; | ||
} | ||
accumulator( v ); |
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.
var randu = require( '@stdlib/random/base/randu' ); | |
var incrnanmmean = require( '@stdlib/stats/incr/nanmmean' ); | |
var accumulator; | |
var v; | |
var i; | |
// Initialize an accumulator: | |
accumulator = incrnanmmean( 5 ); | |
// For each simulated datum, update the moving mean... | |
for ( i = 0; i < 100; i++ ) { | |
if ( randu() < 0.2 ) { | |
v = NaN; | |
} else { | |
v = randu() * 100.0; | |
} | |
accumulator( v ); | |
var uniform = require( '@stdlib/random/base/uniform' ); | |
var bernoulli = require( '@stdlib/random/base/bernoulli' ); | |
var incrnanmmean = require( '@stdlib/stats/incr/nanmmean' ); | |
// Initialize an accumulator: | |
var accumulator = incrnanmmean( 5 ); | |
// For each simulated datum, update the moving mean... | |
var I; | |
for ( i = 0; i < 100; i++ ) { | |
accumulator( ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( 0.0, 100.0 ) ); |
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var randu = require( '@stdlib/random/base/randu' ); |
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.
var randu = require( '@stdlib/random/base/randu' ); |
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.
We will be using iterations as the input
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
v = acc( randu() ); |
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.
v = acc( randu() ); | |
v = acc( i ); |
|
||
'use strict'; | ||
|
||
var randu = require( '@stdlib/random/base/randu' ); |
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.
same as mentioned in the markdown file
// MODULES // | ||
|
||
var tape = require( 'tape' ); | ||
var incrnanmmean = require( '@stdlib/stats/incr/nanmmean/lib' ); |
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.
var incrnanmmean = require( '@stdlib/stats/incr/nanmmean/lib' ); | |
var incrnanmmean = require( './../lib' ); |
@satansin123, the PR looks good, left some comments to make some changes |
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves #5588.
Description
This pull request:
Related Issues
This pull request:
stats/incr/nanmmean
#5588Questions
No.
Other
test -

benchmark -

examples -

Checklist
@stdlib-js/reviewers