From e9d79c9b9dc98ad99b5f306bdc81ef7b110cc9ae Mon Sep 17 00:00:00 2001 From: Muhammad Saad Date: Tue, 8 Apr 2025 08:36:22 +0500 Subject: [PATCH 01/10] feat: add stats/incr/nanmmeanstdev --- 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: na - 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 --- --- .../stats/incr/nanmmeanstdev/README.md | 234 ++++++++++ .../incr/nanmmeanstdev/benchmark/benchmark.js | 69 +++ .../docs/img/equation_arithmetic_mean.svg | 43 ++ ...on_corrected_sample_standard_deviation.svg | 73 +++ .../incr/nanmmeanstdev/docs/types/index.d.ts | 94 ++++ .../incr/nanmmeanstdev/docs/types/test.ts | 78 ++++ .../incr/nanmmeanstdev/examples/index.js | 68 +++ .../stats/incr/nanmmeanstdev/lib/index.js | 57 +++ .../stats/incr/nanmmeanstdev/lib/main.js | 156 +++++++ .../stats/incr/nanmmeanstdev/package.json | 80 ++++ .../stats/incr/nanmmeanstdev/test/test.js | 437 ++++++++++++++++++ 11 files changed, 1389 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_arithmetic_mean.svg create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_corrected_sample_standard_deviation.svg create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md new file mode 100644 index 000000000000..a1ed8ae65802 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md @@ -0,0 +1,234 @@ + + +# incrnanmmeanstdev + +> Compute a moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation] incrementally, ignoring `NaN` values. + +
+ +For a window of size `W`, the [arithmetic mean][arithmetic-mean] is defined as + + + +```math +\bar{x} = \frac{1}{W} \sum_{i=0}^{W-1} x_i +``` + + + + + +and the [corrected sample standard deviation][standard-deviation] is defined as + + + +```math +s = \sqrt{\frac{1}{W-1} \sum_{i=0}^{W-1} ( x_i - \bar{x} )^2} +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev' ); +``` + +#### incrnanmmeanstdev( \[out,] window ) + +Returns an accumulator `function` which incrementally computes a moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation]. The `window` parameter defines the number of values over which to compute the moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation]. + +```javascript +var accumulator = incrnanmmeanstdev( 3 ); +``` + +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 = incrnanmmeanstdev( new Float64Array( 2 ), 3 ); +``` + +#### 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 = incrnanmmeanstdev( 3 ); + +var out = accumulator(); +// returns null + +// Fill the window... +out = accumulator( 2.0 ); // [2.0] +// returns [ 2.0, 0.0 ] + +out = accumulator( 1.0 ); // [2.0, 1.0] +// returns [ 1.5, ~0.71 ] + +out = accumulator( 3.0 ); // [2.0, 1.0, 3.0] +// returns [ 2.0, 1.0 ] + +out = accumulator( NaN ); // [2.0, 1.0, 3.0] +// returns [ 2.0, 1.0 ] + +// Window begins sliding... +out = accumulator( -7.0 ); // [1.0, 3.0, -7.0] +// returns [ -1.0, ~5.29 ] + +out = accumulator( -5.0 ); // [3.0, -7.0, -5.0] +// returns [ -3.0, ~5.29 ] + +out = accumulator(); +// returns [ -3.0, ~5.29 ] +``` + +
+ + + +
+ +## Notes + +- As `W` values are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ArrayBuffer = require( '@stdlib/array/buffer' ); +var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev' ); + +var offset; +var acc; +var buf; +var out; +var ms; +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( incrnanmmeanstdev( out, 5 ) ); +} + +// Simulate data and update the moving sample means and standard deviations... +for ( i = 0; i < 100; i++ ) { + for ( j = 0; j < N; j++ ) { + v = randu() * 100.0 * (j+1); + acc[ j ]( v ); + } +} + +// Print the final results: +console.log( 'Mean\tStDev' ); +for ( i = 0; i < N; i++ ) { + ms = acc[ i ](); + console.log( '%d\t%d', ms[ 0 ].toFixed( 3 ), ms[ 1 ].toFixed( 3 ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js new file mode 100644 index 000000000000..630ad2b0baff --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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( '@stdlib/stats/incr/nanmmeanstdev/package.json' ).name; +var incrmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev/lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrmmeanstdev( (i%5)+1 ); + 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 = incrmmeanstdev( 5 ); + + 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/nanmmeanstdev/docs/img/equation_arithmetic_mean.svg b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_arithmetic_mean.svg new file mode 100644 index 000000000000..1a89a2bfb996 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_arithmetic_mean.svg @@ -0,0 +1,43 @@ + +x overbar equals StartFraction 1 Over upper W EndFraction sigma-summation Underscript i equals 0 Overscript upper W minus 1 Endscripts x Subscript i + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_corrected_sample_standard_deviation.svg b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_corrected_sample_standard_deviation.svg new file mode 100644 index 000000000000..dfe5a3d60cbb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/img/equation_corrected_sample_standard_deviation.svg @@ -0,0 +1,73 @@ + +s equals StartRoot StartFraction 1 Over upper W minus 1 EndFraction sigma-summation Underscript i equals 0 Overscript upper W minus 1 Endscripts left-parenthesis x Subscript i Baseline minus x overbar right-parenthesis squared EndRoot + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts new file mode 100644 index 000000000000..4383586fcdbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts @@ -0,0 +1,94 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 an updated moving arithmetic mean and corrected sample standard deviation. If provided NaN or no value, the accumulator function returns the current moving arithmetic mean and corrected sample standard deviation. +* +* @param x - input value +* @returns output array or null +*/ +type accumulator = ( x?: number ) => ArrayLike | null; + +/** +* Returns an accumulator function which incrementally computes a moving arithmetic mean and corrected sample standard deviation, ignoring NaN values. +* +* ## Notes +* +* - The `W` parameter defines the number of values over which to compute the moving arithmetic mean and corrected sample standard deviation. +* - As `W` values are needed to fill the window buffer, the first `W-1` returned moving arithmetic mean and corrected sample standard deviation are calculated from smaller sample sizes. Until the window is full, each returned moving arithmetic mean and corrected sample standard deviation is calculated from all provided values. +* +* @param out - output array +* @param window - window size +* @throws window size must be a positive integer +* @returns accumulator function +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var accumulator = incrmnanmeanstdev( new Float64Array( 2 ), 3 ); +* +* var mm = accumulator(); +* // returns null +*/ +declare function incrmnanmeanstdev( out: ArrayLike, window: number ): accumulator; + +/** +* Returns an accumulator function which incrementally computes a moving arithmetic mean and corrected sample standard deviation, ignoring NaN values. +* +* ## Notes +* +* - The `W` parameter defines the number of values over which to compute the moving arithmetic mean and corrected sample standard deviation. +* - As `W` values are needed to fill the window buffer, the first `W-1` returned moving arithmetic mean and corrected sample standard deviation are calculated from smaller sample sizes. Until the window is full, each returned moving arithmetic mean and corrected sample standard deviation is calculated from all provided values. +* +* @param window - window size +* @throws window size must be a positive integer +* @returns accumulator function +* +* @example +* var accumulator = incrnanmmeanstdev( 3 ); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0 ); +* // returns [ 2.0, 0.0 ] +* +* v = accumulator( NaN ); +* // returns [ 2.0, 0.0 ] +* +* v = accumulator( -5.0 ); +* // returns [ -1.5, ~4.95 ] +* +* v = accumulator( 3.0 ); +* // returns [ 0.0, ~4.36 ] +* +* v = accumulator(); +* // returns [ 0.0, ~4.36 ] +*/ +declare function incrmnanmeanstdev( window: number ): accumulator; + + +// EXPORTS // + +export = incrmnanmeanstdev; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts new file mode 100644 index 000000000000..5324dc0f8120 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts @@ -0,0 +1,78 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmmeanstdev( 3 ); // $ExpectType accumulator + const out = [ 0.0, 0.0 ]; + incrnanmmeanstdev( out, 3 ); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided a last argument that is not a number... +{ + incrnanmmeanstdev( '5' ); // $ExpectError + incrnanmmeanstdev( true ); // $ExpectError + incrnanmmeanstdev( false ); // $ExpectError + incrnanmmeanstdev( null ); // $ExpectError + incrnanmmeanstdev( {} ); // $ExpectError + incrnanmmeanstdev( ( x: number ): number => x ); // $ExpectError + + const out = [ 0.0, 0.0 ]; + incrnanmmeanstdev( out, '5' ); // $ExpectError + incrnanmmeanstdev( out, true ); // $ExpectError + incrnanmmeanstdev( out, false ); // $ExpectError + incrnanmmeanstdev( out, null ); // $ExpectError + incrnanmmeanstdev( out, {} ); // $ExpectError + incrnanmmeanstdev( out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an output array that is not an array-like object of numbers... +{ + incrnanmmeanstdev( '5', 3 ); // $ExpectError + incrnanmmeanstdev( true, 3 ); // $ExpectError + incrnanmmeanstdev( false, 3 ); // $ExpectError + incrnanmmeanstdev( null, 3 ); // $ExpectError + incrnanmmeanstdev( {}, 3 ); // $ExpectError + incrnanmmeanstdev( ( x: number ): number => x, 3 ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmmeanstdev( 3 ); + + 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 = incrnanmmeanstdev( 3 ); + + 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/nanmmeanstdev/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js new file mode 100644 index 000000000000..0d11f213a989 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 incrnanmmeanstdev = require( './../lib' ); + +var offset; +var acc; +var buf; +var out; +var ms; +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( incrnanmmeanstdev( out, 5 ) ); +} + +// Simulate data and update the moving sample means and standard deviations... +for ( i = 0; i < 100; i++ ) { + for ( j = 0; j < N; j++ ) { + v = randu() * 100.0 * (j+1); + acc[ j ]( v ); + } +} + +// Print the final results: +console.log( 'Mean\tStDev' ); +for ( i = 0; i < N; i++ ) { + ms = acc[ i ](); + console.log( '%d\t%d', ms[ 0 ].toFixed( 3 ), ms[ 1 ].toFixed( 3 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js new file mode 100644 index 000000000000..6d1fab41bb00 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 a moving arithmetic mean and corrected sample standard deviation incrementally, ignoring NaN values. +* +* @module @stdlib/stats/incr/nanmmeanstdev +* +* @example +* var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev' ); +* +* var accumulator = incrnanmmeanstdev( 3 ); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0 ); +* // returns [ 2.0, 0.0 ] +* +* v = accumulator( NaN ); +* // returns [ 2.0, 0.0 ] +* +* v = accumulator( -5.0 ); +* // returns [ -1.5, ~4.95 ] +* +* v = accumulator( 3.0 ); +* // returns [ 0.0, ~4.36 ] +* +* v = accumulator(); +* // returns [ 0.0, ~4.36 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js new file mode 100644 index 000000000000..2872282061ae --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js @@ -0,0 +1,156 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrmmeanstdev = require( '@stdlib/stats/incr/mmeanstdev' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a moving arithmetic mean and corrected sample standard deviation, ignoring `NaN` values. +* +* ## Method +* +* - Let \\(W\\) be a window of \\(N\\) elements over which we want to compute a corrected sample standard deviation. +* +* - We first recognize that the corrected sample standard deviation is defined as the square root of the unbiased sample variance. Accordingly, in order to derive an update equation for the corrected sample standard deviation, deriving an update equation for the unbiased sample variance is sufficient. +* +* - The difference between the unbiased sample variance in a window \\(W_i\\) and the unbiased sample variance in a window \\(W_{i+1})\\) is given by +* +* ```tex +* \Delta s^2 = s_{i+1}^2 - s_{i}^2 +* ``` +* +* - If we multiply both sides by \\(N-1\\), +* +* ```tex +* (N-1)(\Delta s^2) = (N-1)s_{i+1}^2 - (N-1)s_{i}^2 +* ``` +* +* - If we substitute the definition of the unbiased sample variance having the form +* +* ```tex +* \begin{align*} +* s^2 &= \frac{1}{N-1} \biggl( \sum_{i=1}^{N} (x_i - \bar{x})^2 \biggr) \\ +* &= \frac{1}{N-1} \biggl( \sum_{i=1}^{N} (x_i^2 - 2\bar{x}x_i + \bar{x}^2) \biggr) \\ +* &= \frac{1}{N-1} \biggl( \sum_{i=1}^{N} x_i^2 - 2\bar{x} \sum_{i=1}^{N} x_i + \sum_{i=1}^{N} \bar{x}^2) \biggr) \\ +* &= \frac{1}{N-1} \biggl( \sum_{i=1}^{N} x_i^2 - \frac{2N\bar{x}\sum_{i=1}^{N} x_i}{N} + N\bar{x}^2 \biggr) \\ +* &= \frac{1}{N-1} \biggl( \sum_{i=1}^{N} x_i^2 - 2N\bar{x}^2 + N\bar{x}^2 \biggr) \\ +* &= \frac{1}{N-1} \biggl( \sum_{i=1}^{N} x_i^2 - N\bar{x}^2 \biggr) +* \end{align*} +* ``` +* +* we return +* +* ```tex +* (N-1)(\Delta s^2) = \biggl(\sum_{k=1}^N x_k^2 - N\bar{x}_{i+1}^2 \biggr) - \biggl(\sum_{k=0}^{N-1} x_k^2 - N\bar{x}_{i}^2 \biggr) +* ``` +* +* - This can be further simplified by recognizing that subtracting the sums reduces to \\(x_N^2 - x_0^2\\); in which case, +* +* ```tex +* \begin{align*} +* (N-1)(\Delta s^2) &= x_N^2 - x_0^2 - N\bar{x}_{i+1}^2 + N\bar{x}_{i}^2 \\ +* &= x_N^2 - x_0^2 - N(\bar{x}_{i+1}^2 - \bar{x}_{i}^2) \\ +* &= x_N^2 - x_0^2 - N(\bar{x}_{i+1} - \bar{x}_{i})(\bar{x}_{i+1} + \bar{x}_{i}) +* \end{align*} +* ``` +* +* - Recognizing that the difference of means can be expressed +* +* ```tex +* \bar{x}_{i+1} - \bar{x}_i = \frac{1}{N} \biggl( \sum_{k=1}^N x_k - \sum_{k=0}^{N-1} x_k \biggr) = \frac{x_N - x_0}{N} +* ``` +* +* and substituting into the equation above +* +* ```tex +* (N-1)(\Delta s^2) = x_N^2 - x_0^2 - (x_N - x_0)(\bar{x}_{i+1} + \bar{x}_{i}) +* ``` +* +* - Rearranging terms gives us the update equation +* +* ```tex +* \begin{align*} +* (N-1)(\Delta s^2) &= (x_N - x_0)(x_N + x_0) - (x_N - x_0)(\bar{x}_{i+1} + \bar{x}_{i}) +* &= (x_N - x_0)(x_N + x_0 - \bar{x}_{i+1} - \bar{x}_{i}) \\ +* &= (x_N - x_0)(x_N - \bar{x}_{i+1} + x_0 - \bar{x}_{i}) +* \end{align*} +* ``` +* +* @param {Collection} [out] - output array +* @param {PositiveInteger} window - window size +* @throws {TypeError} output argument must be array-like +* @throws {TypeError} window size must be a positive integer +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmmeanstdev( 3 ); +* +* var v = accumulator(); +* // returns null +* +* v = accumulator( 2.0 ); +* // returns [ 2.0, 0.0 ] +* +* v = accumulator( NaN ); +* // returns [ 2.0, 0.0 ] +* +* v = accumulator( -5.0 ); +* // returns [ -1.5, ~4.95 ] +* +* v = accumulator( 3.0 ); +* // returns [ 0.0, ~4.36 ] +* +* v = accumulator(); +* // returns [ 0.0, ~4.36 ] +*/ +function incrnanmmeanstdev( out, window ) { + var mmeanstdev; + + if ( arguments.length === 1 ) { + mmeanstdev = incrmmeanstdev( out ); + } else { + mmeanstdev = incrmmeanstdev( out, window ); + } + return accumulator; + + /** + * If provided a value, the accumulator function returns updated accumulated values. If not provided a value, the accumulator function returns the current accumulated values. + * + * @private + * @param {number} [x] - input value + * @returns {(ArrayLikeObject|null)} output array or null + */ + function accumulator( x ) { + if ( arguments.length === 0 || isnan( x ) ) { + return mmeanstdev(); + } + return mmeanstdev( x ); + } +} + + +// EXPORTS // + +module.exports = incrnanmmeanstdev; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json new file mode 100644 index 000000000000..38801e17f795 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json @@ -0,0 +1,80 @@ +{ + "name": "@stdlib/stats/incr/nanmmeanstdev", + "version": "0.0.0", + "description": "Compute a moving arithmetic mean and corrected sample standard deviation incrementally, ignoring NaN values", + "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", + "central tendency", + "moving mean", + "moving average", + "variance", + "sample", + "sample variance", + "unbiased", + "stdev", + "standard", + "deviation", + "dispersion", + "incremental", + "accumulator", + "sliding window", + "sliding", + "window", + "moving" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js new file mode 100644 index 000000000000..69d85bdee484 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js @@ -0,0 +1,437 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 randu = require( '@stdlib/random/base/randu' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev/lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmmeanstdev, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided a positive integer for the window size', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + 0.0, + 3.14, + true, + 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() { + incrnanmmeanstdev( value ); + }; + } +}); + +tape( 'the function throws an error if not provided a positive integer for the window size', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + 0.0, + 3.14, + 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() { + incrnanmmeanstdev( value ); + }; + } +}); + +tape( 'the function throws an error if not provided a positive integer for the window size (output)', function test( t ) { + var values; + var i; + + values = [ + '5', + -5.0, + 0.0, + 3.14, + 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() { + incrnanmmeanstdev( [ 0.0, 0.0 ], value ); + }; + } +}); + +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() { + incrnanmmeanstdev( value, 3 ); + }; + } +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmmeanstdev( 3 ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function (output)', function test( t ) { + t.equal( typeof incrnanmmeanstdev( [ 0.0, 0.0 ], 3 ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the accumulator function computes a moving arithmetic mean and corrected sample standard deviation incrementally', function test( t ) { + var expected; + var actual; + var data; + var acc; + var N; + var i; + + data = [ 2.0, 3.0, 4.0, -1.0, 3.0, 1.0 ]; + N = data.length; + + acc = incrnanmmeanstdev( 3 ); + + expected = [ + [ 2.0, 0.0 ], + [ 2.5, sqrt( 0.5 ) ], + [ 3.0, sqrt( 1.0 ) ], + [ 2.0, sqrt( 7.0 ) ], + [ 2.0, sqrt( 7.0 ) ], + [ 1.0, sqrt( 4.0 ) ] + ]; + for ( i = 0; i < N; i++ ) { + actual = acc( data[ i ] ); + t.deepEqual( actual, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'the accumulator function computes a moving arithmetic mean and corrected sample standard deviation incrementally (output)', function test( t ) { + var expected; + var actual; + var data; + var acc; + var out; + var N; + var i; + + data = [ 2.0, 3.0, 4.0, -1.0, 3.0, 1.0 ]; + N = data.length; + + out = [ 0.0, 0.0 ]; + acc = incrnanmmeanstdev( out, 3 ); + + expected = [ + [ 2.0, 0.0 ], + [ 2.5, sqrt( 0.5 ) ], + [ 3.0, sqrt( 1.0 ) ], + [ 2.0, sqrt( 7.0 ) ], + [ 2.0, sqrt( 7.0 ) ], + [ 1.0, sqrt( 4.0 ) ] + ]; + for ( i = 0; i < N; i++ ) { + actual = acc( data[ i ] ); + t.strictEqual( actual, out, 'returns expected value' ); + t.deepEqual( actual, expected[ i ], 'returns expected value' ); + } + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current arithmetic mean and corrected sample standard deviation', function test( t ) { + var expected; + var actual; + var delta; + var data; + var tol; + var acc; + var i; + + data = [ 2.0, 3.0, 10.0 ]; + acc = incrnanmmeanstdev( 3 ); + for ( i = 0; i < data.length-1; i++ ) { + acc( data[ i ] ); + } + t.deepEqual( acc(), [ 2.5, sqrt( 0.5 ) ], 'returns expected value' ); + + acc( data[ data.length-1 ] ); + + expected = [ 5.0, sqrt( 19.0 ) ]; + actual = acc(); + + t.equal( actual[ 0 ], expected[ 0 ], 'returns expected value' ); + + delta = abs( actual[ 1 ] - expected[ 1 ] ); + tol = EPS * expected[ 1 ]; + t.equal( delta < tol, true, 'expected: '+expected[ 1 ]+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' ); + + t.end(); +}); + +tape( 'if data has yet to be provided, the accumulator function returns `null`', function test( t ) { + var acc = incrnanmmeanstdev( 3 ); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'if only one datum has been provided, the accumulator function returns `0` for the sample standard deviation', function test( t ) { + var acc = incrnanmmeanstdev( 3 ); + var v = acc( 2.0 ); + t.equal( v[ 0 ], 2.0, 'returns expected value' ); + t.equal( v[ 1 ], 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if the window size is `1`, the accumulator functions always returns `0` for the sample standard deviation', function test( t ) { + var acc; + var out; + var v; + var i; + + acc = incrnanmmeanstdev( 1 ); + for ( i = 0; i < 100; i++ ) { + v = randu() * 100.0; + out = acc( v ); + t.equal( out[ 0 ], v, 'returns expected value' ); + t.equal( out[ 1 ], 0.0, 'returns expected value' ); + } + t.end(); +}); + +tape( 'if provided `NaN`, the accumulator returns current values or null', function test( t ) { + var expected; + var data; + var acc; + var v; + var i; + + acc = incrnanmmeanstdev( 3 ); + + data = [ + NaN, + 3.14, // 3.14 + 3.14, // 3.14, 3.14 + NaN, // 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, 3.14 + 3.14 // 3.14, 3.14, 3.14 + ]; + expected = [ + null, + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ] + ]; + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( i === 0 && isnan( data[ i ] ) ) { + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + + v = acc(); + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + } else { + if ( isnan( data[ i ] ) ) { + t.equal( isnan( v[ 0 ] ), false, 'returns expected value for window '+i ); + t.equal( isnan( v[ 1 ] ), false, 'returns expected value for window '+i ); + } + + t.equal( v[ 0 ], expected[ i ][ 0 ], 'returns expected value for window '+i ); + t.equal( v[ 1 ], expected[ i ][ 1 ], 'returns expected value for window '+i ); + + v = acc(); + t.equal( v[ 0 ], expected[ i ][ 0 ], 'returns expected value for window '+i ); + t.equal( v[ 1 ], expected[ i ][ 1 ], 'returns expected value for window '+i ); + } + } + t.end(); +}); + +tape( 'if provided `NaN`, the accumulator returns current values or null (W=1)', function test( t ) { + var expected; + var data; + var acc; + var v; + var i; + + acc = incrnanmmeanstdev( 1 ); + + data = [ + NaN, + 3.14, + 3.14, + NaN, + 3.14, + 3.14, + 3.14, + NaN, + 3.14, + 3.14, + 3.14, + NaN, + 3.14, + 3.14, + NaN, + NaN, + NaN, + NaN, + 3.14 + ]; + expected = [ + null, + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ], + [ 3.14, 0.0 ] + ]; + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( i === 0 && isnan( data[ i ] ) ) { + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + + v = acc(); + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + } else { + if ( isnan( data[ i ] ) ) { + t.equal( isnan( v[ 0 ] ), false, 'returns expected value for window '+i ); + t.equal( isnan( v[ 1 ] ), false, 'returns expected value for window '+i ); + } + + t.equal( v[ 0 ], expected[ i ][ 0 ], 'returns expected value for window '+i ); + t.equal( v[ 1 ], expected[ i ][ 1 ], 'returns expected value for window '+i ); + + v = acc(); + t.equal( v[ 0 ], expected[ i ][ 0 ], 'returns expected value for window '+i ); + t.equal( v[ 1 ], expected[ i ][ 1 ], 'returns expected value for window '+i ); + } + } + t.end(); +}); From ed60ecc4da785881be0fad37d1c01a9ed9868566 Mon Sep 17 00:00:00 2001 From: Muhammad Saad Date: Tue, 8 Apr 2025 08:47:04 +0500 Subject: [PATCH 02/10] feat: add stats/incr/nanmmeanstdev --- 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js index 630ad2b0baff..39ab5570e83f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js @@ -23,7 +23,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); var pkg = require( '@stdlib/stats/incr/nanmmeanstdev/package.json' ).name; -var incrmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev/lib' ); +var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev/lib' ); // MAIN // @@ -33,7 +33,7 @@ bench( pkg, function benchmark( b ) { var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - f = incrmmeanstdev( (i%5)+1 ); + f = incrnanmmeanstdev( (i%5)+1 ); if ( typeof f !== 'function' ) { b.fail( 'should return a function' ); } @@ -51,7 +51,7 @@ bench( pkg+'::accumulator', function benchmark( b ) { var v; var i; - acc = incrmmeanstdev( 5 ); + acc = incrnanmmeanstdev( 5 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { From bf49adccd781738adc2b9c63984b2239f81e4cb5 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 2 May 2025 03:47:22 +0000 Subject: [PATCH 03/10] chore: update copyright years --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md | 2 +- .../@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js | 2 +- .../@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts | 2 +- .../@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts | 2 +- .../@stdlib/stats/incr/nanmmeanstdev/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js | 2 +- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md index a1ed8ae65802..62df140559eb 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js index 39ab5570e83f..c219c78d3fdd 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts index 4383586fcdbe..023e7ac8c2eb 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts index 5324dc0f8120..84b9d2daa60c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js index 0d11f213a989..b23e15a034cb 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js index 6d1fab41bb00..2eb8f281825a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js index 2872282061ae..93e919fb5bcf 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js index 69d85bdee484..ef5b2b45d4eb 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. From ed19ba208b18c14c8e3dd0ee6582aa7c17f175d2 Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Sat, 3 May 2025 21:20:10 +0500 Subject: [PATCH 04/10] Update lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json Co-authored-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json index 38801e17f795..d734fc8bcad0 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json @@ -13,7 +13,7 @@ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" } ], - "main": "lib", + "main": "./lib", "directories": { "benchmark": "benchmark", "doc": "docs", From 45678f482a0832d1e290c6cda104f0d367ee988b Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Sat, 3 May 2025 21:20:19 +0500 Subject: [PATCH 05/10] Update lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json Co-authored-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json index d734fc8bcad0..82e632c2c645 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json @@ -18,7 +18,7 @@ "benchmark": "benchmark", "doc": "docs", "example": "examples", - "lib": "lib", + "lib": "./lib", "test": "test" }, "types": "./docs/types", From 31807c15fcf6c80fcf637b81ff1b38e9174be820 Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Sat, 3 May 2025 21:30:45 +0500 Subject: [PATCH 06/10] Update package.json Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- .../@stdlib/stats/incr/nanmmeanstdev/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json index 82e632c2c645..7bbd667580ca 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/package.json @@ -15,11 +15,11 @@ ], "main": "./lib", "directories": { - "benchmark": "benchmark", - "doc": "docs", - "example": "examples", + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", "lib": "./lib", - "test": "test" + "test": "./test" }, "types": "./docs/types", "scripts": {}, From 3aa84ba5f89596471d86a0c76be0a9386f5d4bbc Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Tue, 6 May 2025 10:05:53 +0500 Subject: [PATCH 07/10] Update lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js Co-authored-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js index 2eb8f281825a..0006f78ebae6 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute a moving arithmetic mean and corrected sample standard deviation incrementally, ignoring NaN values. +* Compute a moving arithmetic mean and corrected sample standard deviation incrementally, ignoring `NaN` values. * * @module @stdlib/stats/incr/nanmmeanstdev * From 1d1f024f91d21b2390b0ab369878c3288d2cd7f1 Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Tue, 6 May 2025 10:12:12 +0500 Subject: [PATCH 08/10] Update lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js Co-authored-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js index ef5b2b45d4eb..a2668d2f953c 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/test/test.js @@ -26,7 +26,7 @@ var abs = require( '@stdlib/math/base/special/abs' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var EPS = require( '@stdlib/constants/float64/eps' ); -var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev/lib' ); +var incrnanmmeanstdev = require( './../lib' ); // TESTS // From a9afc543ff5229328877063e110c513cbebd7639 Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Tue, 6 May 2025 10:13:17 +0500 Subject: [PATCH 09/10] Update lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md Co-authored-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md index 62df140559eb..3275e117f0c1 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md @@ -68,7 +68,7 @@ var incrnanmmeanstdev = require( '@stdlib/stats/incr/nanmmeanstdev' ); #### incrnanmmeanstdev( \[out,] window ) -Returns an accumulator `function` which incrementally computes a moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation]. The `window` parameter defines the number of values over which to compute the moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation]. +Returns an accumulator function which incrementally computes a moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation], ignoring `NaN` values. The `window` parameter defines the number of values over which to compute the moving [arithmetic mean][arithmetic-mean] and [corrected sample standard deviation][standard-deviation]. ```javascript var accumulator = incrnanmmeanstdev( 3 ); From 4df4cd9573f07da8ce542a465b2449d3845a6ce8 Mon Sep 17 00:00:00 2001 From: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> Date: Sat, 10 May 2025 06:35:28 +0500 Subject: [PATCH 10/10] Update lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md Co-authored-by: Shabareesh Shetty <139731143+ShabiShett07@users.noreply.github.com> Signed-off-by: Muhmmad Saad <106260977+saad-imran-dev@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md index 3275e117f0c1..b097f182e712 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmmeanstdev/README.md @@ -124,6 +124,7 @@ out = accumulator(); ## Notes +- Input values are **not** type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function. - As `W` values are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.