From 4cde934383ea307d5106a62d81be6a2e999eed47 Mon Sep 17 00:00:00 2001 From: hrshya Date: Wed, 12 Mar 2025 16:55:57 +0530 Subject: [PATCH 1/5] feat: add stats/incr/nanmse --- .../@stdlib/stats/incr/nanmse/README.md | 169 ++++++++++++++++++ .../stats/incr/nanmse/benchmark/benchmark.js | 69 +++++++ .../docs/img/equation_mean_squared_error.svg | 60 +++++++ .../@stdlib/stats/incr/nanmse/docs/repl.txt | 30 ++++ .../stats/incr/nanmse/docs/types/index.d.ts | 61 +++++++ .../stats/incr/nanmse/docs/types/test.ts | 69 +++++++ .../stats/incr/nanmse/examples/index.js | 46 +++++ .../@stdlib/stats/incr/nanmse/lib/index.js | 55 ++++++ .../@stdlib/stats/incr/nanmse/lib/main.js | 75 ++++++++ .../@stdlib/stats/incr/nanmse/package.json | 78 ++++++++ .../@stdlib/stats/incr/nanmse/test/test.js | 129 +++++++++++++ 11 files changed, 841 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/README.md create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/docs/img/equation_mean_squared_error.svg create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/package.json create mode 100644 lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md new file mode 100644 index 000000000000..2c7c0fb7c0e1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md @@ -0,0 +1,169 @@ + + +# incrnanmse + +> Compute the [mean squared error][mean-squared-error] (MSE) incrementally, ignoring `NaN` values. + +
+ +The [mean squared error][mean-squared-error] is defined as + + + +```math +\mathop{\mathrm{MSE}} = \frac{1}{n} \sum_{i=0}^{n-1} (y_i - x_i)^2 +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var incrnanmse = require( '@stdlib/stats/incr/nanmse' ); +``` + +#### incrnanmse() + +Returns an accumulator `function` which incrementally computes the [mean squared error][mean-squared-error], ignoring `NaN` values. + +```javascript +var accumulator = incrnanmse(); +``` + +#### accumulator( \[x, y] ) + +If provided input values `x` and `y`, the accumulator function returns an updated [mean squared error][mean-squared-error]. If not provided input values `x` and `y`, the accumulator function returns the current [mean squared error][mean-squared-error]. + +```javascript +var accumulator = incrnanmse(); + +var m = accumulator( 2.0, 3.0 ); +// returns 1.0 + +m = accumulator( 1.0, NaN ); +// returns 1.0 + +m = accumulator( -1.0, -4.0 ); +// returns 5.0 + +m = accumulator( -3.0, 5.0 ); +// returns ~24.67 + +m = accumulator(); +// returns ~24.67 +``` + +
+ + + +
+ +## 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. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmse = require( '@stdlib/stats/incr/nanmse' ); + +var accumulator; +var v1; +var v2; +var i; + +// Initialize an accumulator: +accumulator = incrnanmse(); + +// For each simulated datum, update the mean squared error... +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v1 = NaN; + v2 = NaN; + } else { + v1 = ( randu()*100.0 ) - 50.0; + v2 = ( randu()*100.0 ) - 50.0; + } + accumulator( v1, v2 ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmse/benchmark/benchmark.js new file mode 100644 index 000000000000..de45639e7222 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/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 incrnanmse = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmse(); + 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 = incrnanmse(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( randu()-0.5, randu()-0.5 ); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( v !== v ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/docs/img/equation_mean_squared_error.svg b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/img/equation_mean_squared_error.svg new file mode 100644 index 000000000000..ad5d623df94f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/img/equation_mean_squared_error.svg @@ -0,0 +1,60 @@ + +upper M upper S upper E equals StartFraction 1 Over n EndFraction sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts left-parenthesis y Subscript i Baseline minus x Subscript i Baseline right-parenthesis squared + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/repl.txt new file mode 100644 index 000000000000..a99675919bf4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}() + Returns an accumulator function which incrementally computes the mean + squared error (MSE), ignoring `NaN` values. + + If provided input values, the accumulator function returns an updated mean + squared error. If not provided input values, the accumulator function + returns the current mean squared error. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var m = accumulator() + null + > m = accumulator( 2.0, 3.0 ) + 1.0 + > m = accumulator( 1.0, NaN ) + 1.0 + > m = accumulator( -5.0, 2.0 ) + 25.0 + > m = accumulator() + 25.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/index.d.ts new file mode 100644 index 000000000000..2252f13d33fe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/index.d.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. +*/ + +// TypeScript Version: 4.1 + +/// + +/** +* If provided input values, the accumulator function returns an updated mean squared error. If not provided input values, the accumulator function returns the current mean squared error. +* +* @param x - input value +* @param y - input value +* @returns mean squared error or null +*/ +type accumulator = ( x?: number, y?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes the mean squared error, ignoring `NaN` values. +* +* @returns accumulator function +* +* @example +* var accumulator = incrnanmse(); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0, 3.0 ); +* // returns 1.0 +* +* +* m = accumulator( 1.0, NaN ); +* // returns 1.0 +* +* m = accumulator( -5.0, 2.0 ); +* // returns 25.0 +* +* m = accumulator(); +* // returns 25.0 +*/ +declare function incrnanmse(): accumulator; + + +// EXPORTS // + +export = incrnanmse; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/test.ts new file mode 100644 index 000000000000..2c466e777a52 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/docs/types/test.ts @@ -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. +*/ + +import incrnanmse = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmse(); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided arguments... +{ + incrnanmse( '5' ); // $ExpectError + incrnanmse( 5 ); // $ExpectError + incrnanmse( true ); // $ExpectError + incrnanmse( false ); // $ExpectError + incrnanmse( null ); // $ExpectError + incrnanmse( undefined ); // $ExpectError + incrnanmse( [] ); // $ExpectError + incrnanmse( {} ); // $ExpectError + incrnanmse( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmse(); + + acc(); // $ExpectType number | null + acc( 3.14, 2.0 ); // $ExpectType number | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanmse(); + + acc( '5', 2.0 ); // $ExpectError + acc( true, 2.0 ); // $ExpectError + acc( false, 2.0 ); // $ExpectError + acc( null, 2.0 ); // $ExpectError + acc( [], 2.0 ); // $ExpectError + acc( {}, 2.0 ); // $ExpectError + acc( ( x: number ): number => x, 2.0 ); // $ExpectError + + acc( 3.14, '5' ); // $ExpectError + acc( 3.14, true ); // $ExpectError + acc( 3.14, false ); // $ExpectError + acc( 3.14, null ); // $ExpectError + acc( 3.14, [] ); // $ExpectError + acc( 3.14, {} ); // $ExpectError + acc( 3.14, ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmse/examples/index.js new file mode 100644 index 000000000000..4ad6b5917be6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/examples/index.js @@ -0,0 +1,46 @@ +/** +* @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 incrnanmse = require( './../lib' ); + +var accumulator; +var mse; +var v1; +var v2; +var i; + +// Initialize an accumulator: +accumulator = incrnanmse(); + +// For each simulated datum, update the mean squared error... +console.log( '\nValue\tValue\tMSE\n' ); +for ( i = 0; i < 100; i++ ) { + if ( randu() < 0.2 ) { + v1 = NaN; + v2 = NaN; + } else { + v1 = ( randu()*100.0 ) - 50.0; + v2 = ( randu()*100.0 ) - 50.0; + } + mse = accumulator( v1, v2 ); + console.log( '%d\t%d\t%d', v1.toFixed( 3 ), v2.toFixed( 3 ), ( mse === null ) ? NaN : mse.toFixed( 3 ) ); +} +console.log( '\nFinal MSE: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js new file mode 100644 index 000000000000..a3036537efcc --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js @@ -0,0 +1,55 @@ +/** +* @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 the mean squared error incrementally, ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nanmse +* +* @example +* var incrnanmse = require( '@stdlib/stats/incr/nanmse' ); +* +* var accumulator = incrnanmse(); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0, 3.0 ); +* // returns 1.0 +* +* +* m = accumulator( 1.0, NaN ); +* // returns 1.0 +* +* m = accumulator( -5.0, 2.0 ); +* // returns 25.0 +* +* m = accumulator(); +* // returns 25.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmse/lib/main.js new file mode 100644 index 000000000000..655b1b758b55 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/lib/main.js @@ -0,0 +1,75 @@ +/** +* @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 incrmse = require( '@stdlib/stats/incr/mse' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes the mean squared error, ignoring `NaN` values. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmse(); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0, 3.0 ); +* // returns 1.0 +* +* m = accumulator( 1.0, NaN ); +* // returns 1.0 +* +* m = accumulator( -5.0, 2.0 ); +* // returns 25.0 +* +* m = accumulator(); +* // returns 25.0 +*/ +function incrnanmse() { + var mse = incrmse(); + return accumulator; + + /** + * If provided input values, the accumulator function returns an updated mean squared error. If not provided input values, the accumulator function returns the current mean squared error. + * + * @private + * @param {number} [x] - input value + * @param {number} [y] - input value + * @returns {(number|null)} mean squared error or null + */ + function accumulator( x, y ) { + if ( arguments.length === 0 || isnan( x ) || isnan(y) ) { + return mse(); + } + return mse( x, y ); + } +} + + +// EXPORTS // + +module.exports = incrnanmse; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/package.json b/lib/node_modules/@stdlib/stats/incr/nanmse/package.json new file mode 100644 index 000000000000..7647be05cdc8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/package.json @@ -0,0 +1,78 @@ +{ + "name": "@stdlib/stats/incr/nanmse", + "version": "0.0.0", + "description": "Compute the mean squared error (MSE) 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", + "error", + "err", + "nan", + "msd", + "residuals", + "deviation", + "difference", + "diff", + "delta", + "incremental", + "accumulator", + "time series", + "timeseries", + "forecasting", + "forecast", + "model", + "selection", + "evaluation", + "prediction" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js new file mode 100644 index 000000000000..8775d4f67bec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js @@ -0,0 +1,129 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var incrnanmse = require( './../lib' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmse, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmse(), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the initial accumulated value is `null`', function test( t ) { + var acc = incrnanmse(); + t.equal( acc(), null, 'returns expected value' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes the mean squared error', function test( t ) { + var expected; + var actual; + var delta; + var data; + var acc; + var sum; + var tol; + var N; + var r; + var x; + var y; + var i; + var c; + + data = [ + [ 2.0, 3.0 ], + [ 3.0, -1.0 ], + [ 2.0, 5.0 ], + [ 1.0, NaN ], + [ 4.0, -4.0 ], + [ NaN, 2.0 ], + [ 3.0, 0.0 ], + [ -4.0, 5.0 ] + ]; + N = data.length; + + acc = incrnanmse(); + + sum = 0; + c = 0; + for ( i = 0; i < N; i++ ) { + x = data[ i ][ 0 ]; + y = data[ i ][ 1 ]; + if ( isnan( x ) === false && isnan( y ) === false ) { + r = y - x; + sum += r * r; + c += 1; + expected = sum / c; + } else { + expected = sum / c; + } + actual = acc( x, y ); + if ( actual === expected ) { + t.equal( actual, expected, 'returns expected value' ); + } else { + delta = abs( expected - actual ); + tol = 1.0 * EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. Actual: '+actual+'. Expected: '+expected+'. Delta: '+delta+'. Tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current mean squared error', function test( t ) { + var expected; + var actual; + var delta; + var data; + var acc; + var tol; + var i; + + data = [ + [ 2.0, 3.0 ], + [ NaN, NaN ], + [ 3.0, -5.0 ], + [ 2.0, NaN ], + [ 1.0, 10.0 ] + ]; + acc = incrnanmse(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ][ 0 ], data[ i ][ 1 ] ); + } + actual = acc(); + expected = ( 1.0 + 64.0 + 81.0 ) / 3.0; + delta = abs( expected - actual ); + tol = 1.0 * EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. Actual: '+actual+'. Expected: '+expected+'. Delta: '+delta+'. Tol: '+tol+'.' ); + t.end(); +}); From ac11c51d52ed423d54822b2f24c058035456617f Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:46:51 +0000 Subject: [PATCH 2/5] fix: resolve lint errors --- .../@stdlib/stats/incr/nanmse/README.md | 14 -------------- .../@stdlib/stats/incr/nanmse/test/test.js | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md index 2c7c0fb7c0e1..c6d84e9830c5 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md @@ -136,14 +136,6 @@ console.log( accumulator() ); @@ -156,12 +148,6 @@ console.log( accumulator() ); -[@stdlib/stats/incr/mmse]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mmse - -[@stdlib/stats/incr/rmse]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/rmse - -[@stdlib/stats/incr/rss]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/rss - diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js index 8775d4f67bec..b338f81a5e14 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/test/test.js @@ -23,8 +23,8 @@ var tape = require( 'tape' ); var abs = require( '@stdlib/math/base/special/abs' ); var EPS = require( '@stdlib/constants/float64/eps' ); -var incrnanmse = require( './../lib' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrnanmse = require( './../lib' ); // TESTS // From a6b3e35af6e7187e3d7a5ef50443ff6175da7afe Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Wed, 12 Mar 2025 18:53:55 +0530 Subject: [PATCH 3/5] Update index.js Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js index a3036537efcc..a05cbae5d80f 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/lib/index.js @@ -34,7 +34,6 @@ * m = accumulator( 2.0, 3.0 ); * // returns 1.0 * -* * m = accumulator( 1.0, NaN ); * // returns 1.0 * From 0f94587363bab0594aa7be582604bedfb7f57acd Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Sun, 23 Mar 2025 19:17:12 +0530 Subject: [PATCH 4/5] update README.md Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com> --- .../@stdlib/stats/incr/nanmse/README.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md index c6d84e9830c5..7b059867964e 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md @@ -103,7 +103,8 @@ m = accumulator(); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var uniform = require( '@stdlib/random/base/uniform' ); var incrnanmse = require( '@stdlib/stats/incr/nanmse' ); var accumulator; @@ -116,13 +117,8 @@ accumulator = incrnanmse(); // For each simulated datum, update the mean squared error... for ( i = 0; i < 100; i++ ) { - if ( randu() < 0.2 ) { - v1 = NaN; - v2 = NaN; - } else { - v1 = ( randu()*100.0 ) - 50.0; - v2 = ( randu()*100.0 ) - 50.0; - } + v1 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 ); + v2 = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -50.0, 50.0 ); accumulator( v1, v2 ); } console.log( accumulator() ); @@ -144,12 +140,6 @@ console.log( accumulator() ); From 0caed5ccefd0ea08b83003444c1b385b74f69d17 Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Sun, 23 Mar 2025 19:25:41 +0530 Subject: [PATCH 5/5] update README.md Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com> --- lib/node_modules/@stdlib/stats/incr/nanmse/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md index 7b059867964e..00fc7774d970 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmse/README.md +++ b/lib/node_modules/@stdlib/stats/incr/nanmse/README.md @@ -140,6 +140,8 @@ console.log( accumulator() );