From 1613d00cb3726bc3117198d2d938442027819e0c Mon Sep 17 00:00:00 2001 From: hans Date: Wed, 19 Mar 2025 17:50:42 -0400 Subject: [PATCH 1/6] feat(stats): add package nanmeanvar --- 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 --- --- .../@stdlib/stats/incr/nanmeanvar/README.md | 231 ++++++++++++++++++ .../incr/nanmeanvar/benchmark/benchmark.js | 69 ++++++ .../docs/img/equation_arithmetic_mean.svg | 43 ++++ .../img/equation_unbiased_sample_variance.svg | 61 +++++ .../stats/incr/nanmeanvar/docs/repl.txt | 38 +++ .../incr/nanmeanvar/docs/types/index.d.ts | 72 ++++++ .../stats/incr/nanmeanvar/docs/types/test.ts | 61 +++++ .../stats/incr/nanmeanvar/examples/index.js | 72 ++++++ .../stats/incr/nanmeanvar/lib/index.js | 60 +++++ .../@stdlib/stats/incr/nanmeanvar/lib/main.js | 93 +++++++ .../stats/incr/nanmeanvar/package.json | 73 ++++++ .../stats/incr/nanmeanvar/test/test.js | 203 +++++++++++++++ 12 files changed, 1076 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_arithmetic_mean.svg create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_unbiased_sample_variance.svg create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md new file mode 100644 index 000000000000..89a6fa89833d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md @@ -0,0 +1,231 @@ + + +# incrnanmeanvar + +> Compute an [arithmetic mean][arithmetic-mean] and an [unbiased sample variance][sample-variance] incrementally, ignoring `NaN` value. + +
+ +The [arithmetic mean][arithmetic-mean] is defined as + + + +```math +\bar{x} = \frac{1}{n} \sum_{i=0}^{n-1} x_i +``` + + + + + +and the [unbiased sample variance][sample-variance] is defined as + + + +```math +s^2 = \frac{1}{n-1} \sum_{i=0}^{n-1} ( x_i - \bar{x} )^2 +``` + + + + + +
+ +## Usage + +```javascript +var incrnanmeanvar = require( '@stdlib/stats/incr/nanmeanvar' ); +``` + +#### incrnanmeanvar( \[out] ) + +Returns an accumulator `function` which incrementally computes an [arithmetic mean][arithmetic-mean] and [unbiased sample variance][sample-variance], ignoring `NaN` value. + +```javascript +var accumulator = incrnanmeanvar(); +``` + +By default, the returned accumulator `function` returns the accumulated values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var accumulator = incrnanmeanvar( new Float64Array( 2 ) ); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns updated accumulated values. If not provided an input value `x`, the accumulator function returns the current accumulated values. + +```javascript +var accumulator = incrnanmeanvar(); + +var mv = accumulator(); +// returns null + +mv = accumulator( 2.0 ); +// returns [ 2.0, 0.0 ] + +mv = accumulator( 1.0 ); +// returns [ 1.5, 0.5 ] + +mv = accumulator( 3.0 ); +// returns [ 2.0, 1.0 ] + +mv = accumulator( NaN ); +// returns [ 2.0, 1.0 ] + +mv = accumulator( -7.0 ); +// returns [ -0.25, ~20.92 ] + +mv = accumulator( -5.0 ); +// returns [ -1.2, 20.2 ] + +mv = accumulator(); +// returns [ -1.2, 20.2 ] +``` + +
+ + + +
+ +## Notes + +- Input values are type checked; if a NaN value is provided, the accumulator skips the update and continues to return the previous state. If non-numeric inputs are possible, you are advised to type check and handle them accordingly **before** passing the value to the accumulator function. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var incrnanmeanvar = require( '@stdlib/stats/incr/nanmeanvar' ); + +var offset; +var acc; +var buf; +var out; +var mv; +var N; +var v; +var i; +var j; + +// Define the number of accumulators: +N = 5; + +// Create an array buffer for storing accumulator output: +buf = new ArrayBuffer( N*2*8 ); // 8 bytes per element + +// Initialize accumulators: +acc = []; +for ( i = 0; i < N; i++ ) { + // Compute the byte offset: + offset = i * 2 * 8; // stride=2, bytes_per_element=8 + + // Create a new view for storing accumulated values: + out = new Float64Array( buf, offset, 2 ); + + // Initialize an accumulator which will write results to the view: + acc.push( incrnanmeanvar( out ) ); +} + +// Simulate data and update the sample means and variances... +for ( i = 0; i < 100; i++ ) { + for ( j = 0; j < N; j++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0 * (j+1); + } + acc[ j ]( v ); + } +} + +// Print the final results: +console.log( 'Mean\tVariance' ); +for ( i = 0; i < N; i++ ) { + mv = acc[ i ](); + console.log( '%d\t%d', mv[ 0 ].toFixed( 3 ), mv[ 1 ].toFixed( 3 ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js new file mode 100644 index 000000000000..e3209e9f31d4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var pkg = require( './../package.json' ).name; +var incrnanmeanvar = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmeanvar(); + if ( typeof f !== 'function' ) { + b.fail( 'should return a function' ); + } + } + b.toc(); + if ( typeof f !== 'function' ) { + b.fail( 'should return a function' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::accumulator', function benchmark( b ) { + var acc; + var v; + var i; + + acc = incrnanmeanvar(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu() ); + if ( v.length !== 2 ) { + b.fail( 'should contain two elements' ); + } + } + b.toc(); + if ( v[ 0 ] !== v[ 0 ] || v[ 1 ] !== v[ 1 ] ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_arithmetic_mean.svg b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_arithmetic_mean.svg new file mode 100644 index 000000000000..aea7a5f6687a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_arithmetic_mean.svg @@ -0,0 +1,43 @@ + +x overbar equals StartFraction 1 Over n EndFraction sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts x Subscript i + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_unbiased_sample_variance.svg b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_unbiased_sample_variance.svg new file mode 100644 index 000000000000..1ae1283e7fb1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/img/equation_unbiased_sample_variance.svg @@ -0,0 +1,61 @@ + +s squared equals StartFraction 1 Over n minus 1 EndFraction sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts left-parenthesis x Subscript i Baseline minus x overbar right-parenthesis squared + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt new file mode 100644 index 000000000000..7a724c20bc1d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt @@ -0,0 +1,38 @@ + +{{alias}}( [out] ) + Returns an accumulator function which incrementally computes an arithmetic + mean and unbiased sample variance, ignoring `NaN` value. + + If provided a value, the accumulator function returns updated accumulated + values. If not provided a value, the accumulator function returns the + current accumulated values. + + If provided `NaN`, the update is skipped and the accumulator continues to + return the previous accumulated values. + + + Parameters + ---------- + out: Array|TypedArray (optional) + Output array. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var mv = accumulator() + null + > mv = accumulator( 2.0 ); + > mv = accumulator( -5.0 ); + > mv = accumulator( 3.0 ); + > mv = accumulator( 5.0 ); + > mv = accumulator() + [ 1.25, ~18.92 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts new file mode 100644 index 000000000000..23594f6bcdac --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts @@ -0,0 +1,72 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { ArrayLike } from '@stdlib/types/array'; + +/** +* If provided a value, the accumulator function returns updated results. If not provided a value, the accumulator function returns the current results. +* +* ## Notes +* +* - If provided `NaN`, the arithmetic mean and unbiased sample variance values are equal to `NaN` for all future invocations. +* +* @param x - input value +* @returns output array or null +*/ +type accumulator = ( x?: number ) => ArrayLike | null; + +/** +* Returns an accumulator function which incrementally computes an arithmetic mean and unbiased sample variance, ignoring `NaN` value. +* +* @param out - output array +* @returns accumulator function +* +* @example +* var accumulator = incrnanmeanvar(); +* +* var mv = accumulator(); +* // returns null +* +* mv = accumulator( 2.0 ); +* // returns [ 2.0, 0.0 ] +* +* mv = accumulator( -5.0 ); +* // returns [ -1.5, 24.5 ] +* +* mv = accumulator( 3.0 ); +* // returns [ 0.0, 19.0 ] +* +* mv = accumulator( NaN ); +* // returns [ 0.0, 19.0 ] +* +* mv = accumulator( 5.0 ); +* // returns [ 1.25, ~18.92 ] +* +* mv = accumulator(); +* // returns [ 1.25, ~18.92 ] +*/ +declare function incrnanmeanvar( out?: ArrayLike ): accumulator; + + +// EXPORTS // + +export = incrnanmeanvar; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts new file mode 100644 index 000000000000..37ec2881cb7f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import incrnanmeanvar = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmeanvar(); // $ExpectType accumulator + const out = [ 0.0, 0.0 ]; + incrnanmeanvar( out ); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided an argument that is not an array-like object of numbers... +{ + incrnanmeanvar( '5' ); // $ExpectError + incrnanmeanvar( 5 ); // $ExpectError + incrnanmeanvar( true ); // $ExpectError + incrnanmeanvar( false ); // $ExpectError + incrnanmeanvar( null ); // $ExpectError + incrnanmeanvar( {} ); // $ExpectError + incrnanmeanvar( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmeanvar(); + + acc(); // $ExpectType ArrayLike | null + acc( 3.14 ); // $ExpectType ArrayLike | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanmeanvar(); + + acc( '5' ); // $ExpectError + acc( true ); // $ExpectError + acc( false ); // $ExpectError + acc( null ); // $ExpectError + acc( [] ); // $ExpectError + acc( {} ); // $ExpectError + acc( ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js new file mode 100644 index 000000000000..8420b7ec11c2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var randu = require( '@stdlib/random/base/randu' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var incrnanmeanvar = require( './../lib' ); + +var offset; +var acc; +var buf; +var out; +var mv; +var N; +var v; +var i; +var j; + +// Define the number of accumulators: +N = 5; + +// Create an array buffer for storing accumulator output: +buf = new ArrayBuffer( N*2*8 ); // 8 bytes per element + +// Initialize accumulators: +acc = []; +for ( i = 0; i < N; i++ ) { + // Compute the byte offset: + offset = i * 2 * 8; // stride=2, bytes_per_element=8 + + // Create a new view for storing accumulated values: + out = new Float64Array( buf, offset, 2 ); + + // Initialize an accumulator which will write results to the view: + acc.push( incrnanmeanvar( out ) ); +} + +// Simulate data and update the sample means and variances... +for ( i = 0; i < 100; i++ ) { + for ( j = 0; j < N; j++ ) { + if ( randu() < 0.2 ) { + v = NaN; + } else { + v = randu() * 100.0 * (j+1); + } + acc[ j ]( v ); + } +} + +// Print the final results: +console.log( 'Mean\tVariance' ); +for ( i = 0; i < N; i++ ) { + mv = acc[ i ](); + console.log( '%d\t%d', mv[ 0 ].toFixed( 3 ), mv[ 1 ].toFixed( 3 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js new file mode 100644 index 000000000000..49e0f7f4d96d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute an arithmetic mean and unbiased sample variance incrementally. +* +* @module @stdlib/stats/incr/nanmeanvar +* +* @example +* var incrnanmeanvar = require( '@stdlib/stats/incr/nanmeanvar' ); +* +* var accumulator = incrnanmeanvar(); +* +* var mv = accumulator(); +* // returns null +* +* mv = accumulator( 2.0 ); +* // returns [ 2.0, 0.0 ] +* +* mv = accumulator( -5.0 ); +* // returns [ -1.5, 24.5 ] +* +* mv = accumulator( 3.0 ); +* // returns [ 0.0, 19.0 ] +* +* mv = accumulator( NaN ); +* // returns [ 0.0, 19.0 ] +* +* mv = accumulator( 5.0 ); +* // returns [ 1.25, ~18.92 ] +* +* mv = accumulator(); +* // returns [ 1.25, ~18.92 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js new file mode 100644 index 000000000000..eea3417d971e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; +var incrmeanvar = require( '@stdlib/stats/incr/meanvar' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes an arithmetic mean and unbiased sample variance, ignoring `NaN` value. +* +* ## References +* +* - Welford, B. P. 1962. "Note on a Method for Calculating Corrected Sums of Squares and Products." _Technometrics_ 4 (3). Taylor & Francis: 419–20. doi:[10.1080/00401706.1962.10490022](https://doi.org/10.1080/00401706.1962.10490022). +* - van Reeken, A. J. 1968. "Letters to the Editor: Dealing with Neely's Algorithms." _Communications of the ACM_ 11 (3): 149–50. doi:[10.1145/362929.362961](https://doi.org/10.1145/362929.362961). +* +* @param {Collection} [out] - output array +* @throws {TypeError} output argument must be array-like +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmeanvar(); +* +* var mv = accumulator(); +* // returns null +* +* mv = accumulator( 2.0 ); +* // returns [ 2.0, 0.0 ] +* +* mv = accumulator( -5.0 ); +* // returns [ -1.5, 24.5 ] +* +* mv = accumulator( 3.0 ); +* // returns [ 0.0, 19.0 ] +* +* mv = accumulator( NaN ); +* // returns [ 0.0, 19.0 ] +* +* mv = accumulator( 5.0 ); +* // returns [ 1.25, ~18.92 ] +* +* mv = accumulator(); +* // returns [ 1.25, ~18.92 ] +*/ +function incrnanmeanvar( out ) { + var meanvar; + if ( arguments.length > 0 ) { + meanvar = incrmeanvar( out ); + } else { + meanvar = incrmeanvar(); + } + return accumulator; + + /** + * If provided a value, the accumulator function returns updated results. If not provided a value, the accumulator function returns the current results. + * + * @private + * @param {number} [x] - input value + * @returns {(ArrayLikeObject|null)} output array or null + */ + function accumulator( x ) { + if ( arguments.length === 0 || isnan( x ) || !isNumber( x ) ) { + return meanvar(); + } + return meanvar( x ); + } +} + + +// EXPORTS // + +module.exports = incrnanmeanvar; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json new file mode 100644 index 000000000000..63764769ed7a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/stats/incr/nanmeanvar", + "version": "0.0.0", + "description": "Compute an arithmetic mean and unbiased sample variance incrementally.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "average", + "avg", + "mean", + "arithmetic mean", + "variance", + "sample variance", + "unbiased", + "var", + "dispersion", + "standard deviation", + "stdev", + "central tendency", + "incremental", + "accumulator" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js new file mode 100644 index 000000000000..aeb4f0065d3f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js @@ -0,0 +1,203 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var incrnanmeanvar = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmeanvar, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided an array-like object for an output argument', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + true, + false, + null, + void 0, + NaN, + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + incrnanmeanvar( value ); + }; + } +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmeanvar(), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function (output)', function test( t ) { + t.equal( typeof incrnanmeanvar( [ 0.0, 0.0 ] ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes an arithmetic mean and unbiased sample variance', function test( t ) { + var expected; + var actual; + var data; + var acc; + var N; + var i; + + data = [ 2.0, NaN, 3.0, 2.0, NaN, 4.0, 3.0, 4.0 ]; + N = data.length; + + // Test against Julia: + expected = [ + [ 2.0, 0.0 ], + [ 2.0, 0.0 ], + [ 2.5, 0.5 ], + [ 7.0/3.0, 0.33333333333333337 ], + [ 7.0/3.0, 0.33333333333333337 ], + [ 11.0/4.0, 0.9166666666666666 ], + [ 14.0/5.0, 0.7 ], + [ 18.0/6.0, 0.8 ] + ]; + + acc = incrnanmeanvar(); + + for ( i = 0; i < N; i++ ) { + actual = acc( data[ i ] ); + t.deepEqual( actual, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the accumulator function incrementally computes an arithmetic mean and unbiased sample variance (output)', function test( t ) { + var expected; + var actual; + var data; + var acc; + var out; + var N; + var i; + + data = [ 2.0, NaN, 3.0, 2.0, NaN, 4.0, 3.0, 4.0 ]; + N = data.length; + + // Test against Julia: + expected = [ + [ 2.0, 0.0 ], + [ 2.0, 0.0 ], + [ 2.5, 0.5 ], + [ 7.0/3.0, 0.33333333333333337 ], + [ 7.0/3.0, 0.33333333333333337 ], + [ 11.0/4.0, 0.9166666666666666 ], + [ 14.0/5.0, 0.7 ], + [ 18.0/6.0, 0.8 ] + ]; + out = [ 0.0, 0.0 ]; + acc = incrnanmeanvar( out ); + + for ( i = 0; i < N; i++ ) { + actual = acc( data[ i ] ); + t.equal( actual, out, 'returns output array' ); + t.deepEqual( actual, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current mean and unbiased sample variance', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, 3.0, NaN, 1.0 ]; + acc = incrnanmeanvar(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.deepEqual( acc(), [ 2.0, 1.0 ], 'returns expected value' ); + t.end(); +}); + +tape( 'if data has yet to be provided, the accumulator function returns `null`', function test( t ) { + var acc = incrnanmeanvar(); + t.equal( acc(), null, 'returns null' ); + t.equal( acc(), null, 'returns null' ); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'the sample variance is `0` until at least 2 datums have been provided', function test( t ) { + var acc; + var mv; + + acc = incrnanmeanvar(); + + mv = acc(); + t.equal( mv, null, 'returns null' ); + + mv = acc( 3.0 ); + t.equal( mv[ 1 ], 0.0, 'returns expected value' ); + + mv = acc(); + t.equal( mv[ 1 ], 0.0, 'returns expected value' ); + + mv = acc( 5.0 ); + t.notEqual( mv[ 1 ], 0.0, 'does not return 0' ); + + mv = acc(); + t.notEqual( mv[ 1 ], 0.0, 'does not return 0' ); + + t.end(); +}); + +tape( 'if the first value is NaN, the accumulator returns its initial state', function test( t ) { + var state; + var acc; + + acc = incrnanmeanvar(); + + // First update is NaN, so no valid update occurs: + state = acc( NaN ); + t.equal( state, null, 'returns null for initial state when first input is NaN' ); + + // Subsequent call without an update should still return null: + state = acc(); + t.equal( state, null, 'remains at initial state (null) when no valid update is provided' ); + + // Now provide a valid update to see the state change: + state = acc( 2.0 ); + t.deepEqual( state, [ 2.0, 0.0 ], 'updates state correctly after a valid input following an initial NaN' ); + t.end(); +}); From eb5273ffe00e6f2f4a4ddbf6df859189033e1078 Mon Sep 17 00:00:00 2001 From: hans Date: Sat, 22 Mar 2025 11:06:56 -0400 Subject: [PATCH 2/6] fix(stats): update careless errors --- 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: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt | 1 + lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt index 7a724c20bc1d..3b276741410b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt @@ -29,6 +29,7 @@ > mv = accumulator( 2.0 ); > mv = accumulator( -5.0 ); > mv = accumulator( 3.0 ); + > mv = accumulator( NaN ); > mv = accumulator( 5.0 ); > mv = accumulator() [ 1.25, ~18.92 ] diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json index 63764769ed7a..6c9df94e61e7 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/stats/incr/nanmeanvar", "version": "0.0.0", - "description": "Compute an arithmetic mean and unbiased sample variance incrementally.", + "description": "Compute an arithmetic mean and unbiased sample variance incrementally, ignoring `NaN` value.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 35df8d296b3102db63d8d565575de7ca7e803780 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 11 Jul 2026 22:34:26 -0500 Subject: [PATCH 3/6] fix: address review feedback --- lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md | 4 ++-- lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt | 2 +- .../@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts | 4 ++-- lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md index 89a6fa89833d..7c8a61626b2b 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md @@ -20,7 +20,7 @@ limitations under the License. # incrnanmeanvar -> Compute an [arithmetic mean][arithmetic-mean] and an [unbiased sample variance][sample-variance] incrementally, ignoring `NaN` value. +> Compute an [arithmetic mean][arithmetic-mean] and an [unbiased sample variance][sample-variance] incrementally, ignoring `NaN` values.
@@ -64,7 +64,7 @@ var incrnanmeanvar = require( '@stdlib/stats/incr/nanmeanvar' ); #### incrnanmeanvar( \[out] ) -Returns an accumulator `function` which incrementally computes an [arithmetic mean][arithmetic-mean] and [unbiased sample variance][sample-variance], ignoring `NaN` value. +Returns an accumulator `function` which incrementally computes an [arithmetic mean][arithmetic-mean] and [unbiased sample variance][sample-variance], ignoring `NaN` values. ```javascript var accumulator = incrnanmeanvar(); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt index 3b276741410b..f28b6bb1c474 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( [out] ) Returns an accumulator function which incrementally computes an arithmetic - mean and unbiased sample variance, ignoring `NaN` value. + mean and unbiased sample variance, ignoring `NaN` values. If provided a value, the accumulator function returns updated accumulated values. If not provided a value, the accumulator function returns the diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts index 23594f6bcdac..4f868f308744 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { ArrayLike } from '@stdlib/types/array'; * * ## Notes * -* - If provided `NaN`, the arithmetic mean and unbiased sample variance values are equal to `NaN` for all future invocations. +* - If provided `NaN`, the value is ignored and the accumulator function returns the current accumulated values. * * @param x - input value * @returns output array or null @@ -35,7 +35,7 @@ import { ArrayLike } from '@stdlib/types/array'; type accumulator = ( x?: number ) => ArrayLike | null; /** -* Returns an accumulator function which incrementally computes an arithmetic mean and unbiased sample variance, ignoring `NaN` value. +* Returns an accumulator function which incrementally computes an arithmetic mean and unbiased sample variance, ignoring `NaN` values. * * @param out - output array * @returns accumulator function diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js index 49e0f7f4d96d..d521c066774c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute an arithmetic mean and unbiased sample variance incrementally. +* Compute an arithmetic mean and unbiased sample variance incrementally, ignoring `NaN` values. * * @module @stdlib/stats/incr/nanmeanvar * diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js index eea3417d971e..9e5215ece36e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js @@ -28,7 +28,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); // MAIN // /** -* Returns an accumulator function which incrementally computes an arithmetic mean and unbiased sample variance, ignoring `NaN` value. +* Returns an accumulator function which incrementally computes an arithmetic mean and unbiased sample variance, ignoring `NaN` values. * * ## References * diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json index 6c9df94e61e7..ec64e00b032c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/stats/incr/nanmeanvar", "version": "0.0.0", - "description": "Compute an arithmetic mean and unbiased sample variance incrementally, ignoring `NaN` value.", + "description": "Compute an arithmetic mean and unbiased sample variance incrementally, ignoring `NaN` values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 34a22f55721045beb27c23f2e9fb769f1b8350b4 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 11 Jul 2026 23:02:30 -0500 Subject: [PATCH 4/6] chore: update copyright years --- lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md | 2 +- .../@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nanmeanvar/docs/types/test.ts | 2 +- .../@stdlib/stats/incr/nanmeanvar/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md index 7c8a61626b2b..dad0ddf01b35 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +Copyright (c) 2026 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js index e3209e9f31d4..9000fac9cdaa 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts index 4f868f308744..541dd125700c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts index 37ec2881cb7f..4b6565bbc5da 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js index 8420b7ec11c2..99ec426463e2 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js index d521c066774c..6c8b4e3d3f81 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js index 9e5215ece36e..6e566e6a3d09 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js index aeb4f0065d3f..5f2a526e7bf9 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 77a196f6e64ed78bc983587144bfbd6edacac2fc Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 11 Jul 2026 23:22:44 -0500 Subject: [PATCH 5/6] fix: address additional review feedback --- .../@stdlib/stats/incr/nanmeanvar/README.md | 25 +++---------------- .../stats/incr/nanmeanvar/docs/repl.txt | 16 +++++++----- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md index dad0ddf01b35..66c1ec851e1a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/README.md @@ -54,6 +54,10 @@ s^2 = \frac{1}{n-1} \sum_{i=0}^{n-1} ( x_i - \bar{x} )^2 +
+ + +
## Usage @@ -193,15 +197,6 @@ for ( i = 0; i < N; i++ ) { @@ -214,18 +209,6 @@ for ( i = 0; i < N; i++ ) { [sample-variance]: https://en.wikipedia.org/wiki/Variance - - -[@stdlib/stats/incr/mean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mean - -[@stdlib/stats/incr/meanstdev]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/meanstdev - -[@stdlib/stats/incr/mmeanvar]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mmeanvar - -[@stdlib/stats/incr/variance]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/variance - - -
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt index f28b6bb1c474..1862fbb8518d 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/docs/repl.txt @@ -10,7 +10,6 @@ If provided `NaN`, the update is skipped and the accumulator continues to return the previous accumulated values. - Parameters ---------- out: Array|TypedArray (optional) @@ -26,11 +25,16 @@ > var accumulator = {{alias}}(); > var mv = accumulator() null - > mv = accumulator( 2.0 ); - > mv = accumulator( -5.0 ); - > mv = accumulator( 3.0 ); - > mv = accumulator( NaN ); - > mv = accumulator( 5.0 ); + > mv = accumulator( 2.0 ) + [ 2.0, 0.0 ] + > mv = accumulator( -5.0 ) + [ -1.5, 24.5 ] + > mv = accumulator( 3.0 ) + [ 0.0, 19.0 ] + > mv = accumulator( NaN ) + [ 0.0, 19.0 ] + > mv = accumulator( 5.0 ) + [ 1.25, ~18.92 ] > mv = accumulator() [ 1.25, ~18.92 ] From 91dbb3fd9374d1319e1fd703e1431e02d532695f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 11 Jul 2026 23:43:57 -0500 Subject: [PATCH 6/6] fix: use format for benchmark names --- .../@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js index 9000fac9cdaa..fb58216a6107 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmeanvar/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var incrnanmeanvar = require( './../lib' ); @@ -46,7 +47,7 @@ bench( pkg, function benchmark( b ) { b.end(); }); -bench( pkg+'::accumulator', function benchmark( b ) { +bench( format( '%s::accumulator', pkg ), function benchmark( b ) { var acc; var v; var i;