diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/README.md b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/README.md new file mode 100644 index 000000000000..b09a6f8544fa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/README.md @@ -0,0 +1,126 @@ + + +# incrnanmmaxabs + +> Compute a moving maximum absolute value incrementally, ignoring `NaN` values. + +
+ +## Usage + +```javascript +var incrnanmmaxabs = require( '@stdlib/stats/incr/nanmmaxabs' ); +``` + +#### incrnanmmaxabs( window ) + +Returns an accumulator function which incrementally computes a moving maximum absolute value. The `window` parameter defines the number of values over which to compute the moving maximum absolute value. + +```javascript +var accumulator = incrnanmmaxabs( 3 ); +``` + +#### accumulator( \[x] ) + +If provided an input value `x`, the accumulator function returns an updated maximum absolute value. If not provided an input value `x`, the accumulator function returns the current maximum absolute value. + +```javascript +var accumulator = incrnanmmaxabs( 3 ); + +var m = accumulator(); +// returns null + +// Fill the window... +m = accumulator( 2.0 ); // [2.0] +// returns 2.0 + +m = accumulator( NaN ); // [2.0, NaN] +// returns 2.0 + +m = accumulator( 1.0 ); // [2.0, 1.0] +// returns 2.0 + +m = accumulator( 3.0 ); // [2.0, 1.0, 3.0] +// returns 3.0 + +// Window begins sliding... +m = accumulator( -7.0 ); // [1.0, 3.0, -7.0] +// returns 7.0 + +m = accumulator( -5.0 ); // [3.0, -7.0, -5.0] +// returns 7.0 + +m = accumulator(); +// returns 7.0 +``` + +
+ + + +
+ +## 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. + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var incrnanmmaxabs = require( '@stdlib/stats/incr/nanmmaxabs' ); + +// Initialize an accumulator: +var accumulator = incrnanmmaxabs( 5 ); + +// For each simulated datum, update the moving maximum absolute value... +var i; +for ( i = 0; i < 100; i++ ) { + accumulator( ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -100.0, 100.0 ) ); +} +console.log( accumulator() ); +``` + +
+ + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/benchmark/benchmark.js new file mode 100644 index 000000000000..84407d52e67e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/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 incrnanmmaxabs = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmmaxabs( (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 = incrnanmmaxabs( 5 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( 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/nanmmaxabs/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/repl.txt new file mode 100644 index 000000000000..ed9992d7d252 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/repl.txt @@ -0,0 +1,47 @@ + +{{alias}}( W ) + Returns an accumulator function which incrementally computes a moving + maximum absolute value, ignoring `NaN` values. + + The `W` parameter defines the number of values over which to compute the + moving maximum absolute value. + + If provided a value, the accumulator function returns an updated moving + maximum absolute value. If not provided a value, the accumulator function + returns the current moving maximum absolute value. + + 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. + + Parameters + ---------- + W: integer + Window size. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}( 3 ); + > var m = accumulator() + null + > m = accumulator( 2.0 ) + 2.0 + > m = accumulator( NaN ) + 2.0 + > m = accumulator( -5.0 ) + 5.0 + > m = accumulator( 3.0 ) + 5.0 + > m = accumulator( 5.0 ) + 5.0 + > m = accumulator() + 5.0 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/types/index.d.ts new file mode 100644 index 000000000000..3c0250ed22d9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/types/index.d.ts @@ -0,0 +1,70 @@ +/* +* @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 a value, returns an updated maximum absolute value; otherwise, returns the current maximum absolute value. +* +* @param x - value +* @returns maximum absolute value +*/ +type accumulator = ( x?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes a moving maximum absolute value, ignoring `NaN` values. +* +* ## Notes +* +* - The `W` parameter defines the number of values over which to compute the moving maximum absolute value. +* - 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. +* +* @param W - window size +* @throws must provide a positive integer +* @returns accumulator function +* +* @example +* var accumulator = incrnanmmaxabs( 3 ); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0 ); +* // returns 2.0 +* +* m = accumulator( NaN ); +* // returns 2.0 +* +* m = accumulator( -5.0 ); +* // returns 5.0 +* +* m = accumulator( 3.0 ); +* // returns 5.0 +* +* m = accumulator( 5.0 ); +* // returns 5.0 +* +* m = accumulator(); +* // returns 5.0 +*/ +declare function incrnanmmaxabs( W: number ): accumulator; + + +// EXPORTS // + +export = incrnanmmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/types/test.ts new file mode 100644 index 000000000000..f3593ea2956e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/docs/types/test.ts @@ -0,0 +1,66 @@ +/* +* @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 incrnanmmaxabs = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmmaxabs( 3 ); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided an argument that is not a number... +{ + incrnanmmaxabs( '5' ); // $ExpectError + incrnanmmaxabs( true ); // $ExpectError + incrnanmmaxabs( false ); // $ExpectError + incrnanmmaxabs( null ); // $ExpectError + incrnanmmaxabs( undefined ); // $ExpectError + incrnanmmaxabs( [] ); // $ExpectError + incrnanmmaxabs( {} ); // $ExpectError + incrnanmmaxabs( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + incrnanmmaxabs(); // $ExpectError + incrnanmmaxabs( 2, 5 ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmmaxabs( 3 ); + + acc(); // $ExpectType number | null + acc( 3.14 ); // $ExpectType number | null +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanmmaxabs( 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/nanmmaxabs/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/examples/index.js new file mode 100644 index 000000000000..c8191813b40c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/examples/index.js @@ -0,0 +1,37 @@ +/** +* @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 uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var incrnanmmaxabs = require( './../lib' ); + +// Initialize an accumulator: +var accumulator = incrnanmmaxabs( 5 ); + +// For each simulated datum, update the moving maximum absolute value... +console.log( '\nValue\tMaxAbs\n' ); +var m; +var v; +var i; +for ( i = 0; i < 100; i++ ) { + v = ( bernoulli( 0.8 ) < 1 ) ? NaN : uniform( -100.0, 100.0 ); + m = accumulator( v ); + console.log( '%d\t%d', v.toFixed( 3 ), ( m === null ) ? NaN : m.toFixed( 3 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/lib/index.js new file mode 100644 index 000000000000..1367f7d4bf7e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/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 a moving maximum absolute value incrementally, ignoring `NaN` values. +* +* @module @stdlib/stats/incr/nanmmaxabs +* +* @example +* var incrnanmmaxabs = require( '@stdlib/stats/incr/nanmmaxabs' ); +* +* var accumulator = incrnanmmaxabs( 3 ); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0 ); +* // returns 2.0 +* +* m = accumulator( NaN ); +* // returns 2.0 +* +* m = accumulator( -5.0 ); +* // returns 5.0 +* +* m = accumulator( 3.0 ); +* // returns 5.0 +* +* m = accumulator( 5.0 ); +* // returns 5.0 +* +* m = accumulator(); +* // returns 5.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/lib/main.js new file mode 100644 index 000000000000..ff6253b3dfe6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/lib/main.js @@ -0,0 +1,82 @@ +/** +* @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 incrmmaxabs = require( '@stdlib/stats/incr/mmaxabs' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes a moving maximum absolute value, ignoring `NaN` values. +* +* @param {PositiveInteger} W - window size +* @throws {TypeError} must provide a positive integer +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmmaxabs( 3 ); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0 ); +* // returns 2.0 +* +* m = accumulator( NaN ); +* // returns 2.0 +* +* m = accumulator( -5.0 ); +* // returns 5.0 +* +* m = accumulator( 3.0 ); +* // returns 5.0 +* +* m = accumulator( 5.0 ); +* // returns 5.0 +* +* m = accumulator(); +* // returns 5.0 +*/ +function incrnanmmaxabs( W ) { + var mmaxabs = incrmmaxabs( W ); + return accumulator; + + /** + * If provided a value, the accumulator function returns an updated maximum absolute value. If not provided a value, the accumulator function returns the current maximum absolute value, ignoring `NaN` values. + * + * @private + * @param {number} [x] - input value + * @returns {(number|null)} maximum absolute value or null + */ + function accumulator( x ) { + if ( arguments.length === 0 || isnan( x ) ) { + return mmaxabs(); + } + return mmaxabs( x ); + } +} + + +// EXPORTS // + +module.exports = incrnanmmaxabs; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/package.json b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/package.json new file mode 100644 index 000000000000..26a45b681551 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/stats/incr/nanmmaxabs", + "version": "0.0.0", + "description": "Compute a moving maximum absolute value 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", + "maximum", + "max", + "absolute", + "abs", + "magnitude", + "extreme", + "extent", + "range", + "incremental", + "accumulator", + "moving max", + "sliding window", + "sliding", + "window", + "moving" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/test/test.js new file mode 100644 index 000000000000..1618402d1a90 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmmaxabs/test/test.js @@ -0,0 +1,227 @@ +/** +* @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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrnanmmaxabs = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmmaxabs, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided a positive integer', 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() { + incrnanmmaxabs( value ); + }; + } +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.equal( typeof incrnanmmaxabs( 3 ), 'function', 'returns a function' ); + t.end(); +}); + +tape( 'the accumulator function computes a moving maximum absolute value incrementally', function test( t ) { + var expected; + var actual; + var data; + var acc; + var N; + var i; + + data = [ 2.0, -3.0, 2.0, NaN, -4.0, 3.0, 4.0, NaN, -2.0, 2.0, -2.0, 1.0 ]; + N = data.length; + + acc = incrnanmmaxabs( 3 ); + + actual = []; + for ( i = 0; i < N; i++ ) { + actual.push( acc( data[ i ] ) ); + } + expected = [ 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0, 4.0, 2.0, 2.0, 2.0 ]; + + t.deepEqual( actual, expected, 'returns expected incremental results' ); + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current maximum absolute value', function test( t ) { + var data; + var acc; + var i; + + data = [ 2.0, NaN, -3.0, -5.0, NaN, 4.0 ]; + acc = incrnanmmaxabs( 2 ); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ] ); + } + t.equal( acc(), 5.0, 'returns expected value' ); + t.end(); +}); + +tape( 'if data has yet to be provided, the accumulator function returns `null`', function test( t ) { + var acc = incrnanmmaxabs( 3 ); + t.equal( acc(), null, 'returns null' ); + t.end(); +}); + +tape( 'the accumulator function correctly handles signed zeros', function test( t ) { + var expected; + var data; + var acc; + var v; + var i; + + acc = incrnanmmaxabs( 3 ); + + data = [ + -0.0, // -0 + 0.0, // -0, 0 + -0.0, // -0, 0, -0 + -0.0, // 0, -0, -0 + -0.0, // -0, -0, -0 + 0.0, // -0, -0, 0 + -0.0, // -0, 0, -0 + -0.0, // 0, -0, -0 + -0.0, // -0, -0, -0 + 0.0, // -0, -0, 0 + 0.0, // -0, 0, 0 + 0.0, // 0, 0, 0 + -0.0 // 0, 0, -0 + ]; + expected = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( isPositiveZero( expected[ i ] ) ) { + t.equal( isPositiveZero( v ), true, 'returns expected value for window '+i ); + } else { + t.equal( isNegativeZero( v ), true, 'returns expected value for window '+i ); + } + } + t.end(); +}); + +tape( 'ignores `NaN` values and correctly computes moving maximum absolute value incrementally', function test( t ) { + var expected; + var data; + var acc; + var v; + var i; + + acc = incrnanmmaxabs( 3 ); + + data = [ + NaN, // NaN + 3.14, // NaN, 3.14 + 3.14, // NaN, 3.14, 3.14 + NaN, // 3.14, 3.14, NaN + 3.14, // 3.14, NaN, 3.14 + 3.14, // NaN, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, NaN + 3.14, // 3.14, NaN, 3.14 + 3.14, // NaN, 3.14, 3.14 + 3.14, // 3.14, 3.14, 3.14 + NaN, // 3.14, 3.14, NaN + 3.14, // 3.14, NaN, 3.14 + 3.14, // NaN, 3.14, 3.14 + NaN, // 3.14, 3.14, NaN + NaN, // 3.14, NaN, NaN + NaN, // NaN, NaN, NaN + NaN, // NaN, NaN, NaN + 3.14 // NaN, NaN, 3.14 + ]; + expected = [ + null, + 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, + 3.14, + 3.14, + 3.14 + ]; + for ( i = 0; i < data.length; i++ ) { + v = acc( data[ i ] ); + if ( isnan( expected[ i ] ) ) { + t.equal( isnan( v ), true, 'returns expected value for window '+i ); + } else { + t.equal( v, expected[ i ], 'returns expected value for window '+i ); + } + } + t.end(); +});