diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/README.md b/lib/node_modules/@stdlib/stats/incr/nanmape/README.md new file mode 100644 index 000000000000..1922d9bd7831 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/README.md @@ -0,0 +1,182 @@ + + +# incrnanmape + +> Compute the [mean absolute percentage error][mean-absolute-percentage-error] (MAPE) incrementally, ignoring `NaN` values. + +
+ +The [mean absolute percentage error][mean-absolute-percentage-error] is defined as + + + +```math +\mathop{\mathrm{MAPE}} = \frac{100}{n} \sum_{i=0}^{n-1} \biggl| \frac{a_i - f_i}{a_i} \biggr| +``` + + + + + +where `f_i` is the forecast value and `a_i` is the actual value. + +
+ + + +
+ +## Usage + +```javascript +var incrnanmape = require( '@stdlib/stats/incr/nanmape' ); +``` + +#### incrnanmape() + +Returns an accumulator `function` which incrementally computes the [mean absolute percentage error][mean-absolute-percentage-error]. + +```javascript +var accumulator = incrnanmape(); +``` + +#### accumulator( \[f, a] ) + +If provided input values `f` and `a`, the accumulator function returns an updated [mean absolute percentage error][mean-absolute-percentage-error]. If not provided input values `f` and `a`, the accumulator function returns the current [mean absolute percentage error][mean-absolute-percentage-error]. + +```javascript +var accumulator = incrnanmape(); + +var m = accumulator( 2.0, 3.0 ); +// returns ~33.33 + +m = accumulator( 1.0, 4.0 ); +// returns ~54.17 + +m = accumulator( NaN, 4.0 ); +// returns ~54.17 + +m = accumulator( 3.0, 5.0 ); +// returns ~49.44 + +m = accumulator( 3.0, NaN ); +// returns ~49.44 + +m = accumulator( NaN, NaN ); +// returns ~49.44 + +m = accumulator(); +// returns ~49.44 +``` + +
+ + + +
+ +## 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. + +- **Warning**: the [mean absolute percentage error][mean-absolute-percentage-error] has several shortcomings: + + - The measure is **not** suitable for intermittent demand patterns (i.e., when `a_i` is `0`). + - The [mean absolute percentage error][mean-absolute-percentage-error] is not symmetrical, as the measure cannot exceed 100% for forecasts which are too "low" and has no limit for forecasts which are too "high". + - When used to compare the accuracy of forecast models (e.g., predicting demand), the measure is biased toward forecasts which are too low. + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var incrnanmape = require( '@stdlib/stats/incr/nanmape' ); + +var accumulator; +var v1; +var v2; +var i; + +// Initialize an accumulator: +accumulator = incrnanmape(); + +// For each simulated datum, update the mean absolute percentage error... +console.log( '\nValue\tValue\tMAPE\n' ); +for ( i = 0; i < 100; i++ ) { + v1 = ( randu() < 0.2 ) ? NaN : randu() * 100.0; + v2 = ( randu() < 0.2 ) ? NaN : randu() * 100.0; + accumulator( v1, v2 ); +} +console.log( '\nFinal MAPE: %d\n', accumulator() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmape/benchmark/benchmark.js new file mode 100644 index 000000000000..0907f47d778b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/benchmark/benchmark.js @@ -0,0 +1,68 @@ +/** +* @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 pkg = require( './../package.json' ).name; +var incrnanmape = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var f; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + f = incrnanmape(); + 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 = incrnanmape(); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = acc( i+0.5, i+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/nanmape/docs/img/equation_mean_absolute_percentage_error.svg b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/img/equation_mean_absolute_percentage_error.svg new file mode 100644 index 000000000000..9367280b2aae --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/img/equation_mean_absolute_percentage_error.svg @@ -0,0 +1,87 @@ + +upper M upper A upper P upper E equals StartFraction 100 Over n EndFraction sigma-summation Underscript i equals 0 Overscript n minus 1 Endscripts StartAbsoluteValue StartFraction a Subscript i Baseline minus f Subscript i Baseline Over a Subscript i Baseline EndFraction EndAbsoluteValue + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/repl.txt new file mode 100644 index 000000000000..7c7d0592dc50 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/repl.txt @@ -0,0 +1,31 @@ + +{{alias}}() + Returns an accumulator function which incrementally computes the mean + absolute percentage error (MAPE), ignoring `NaN` values. + + If provided input values, the accumulator function returns an updated mean + absolute percentage error. If not provided input values, the accumulator + function returns the current mean absolute percentage error. + + Returns + ------- + acc: Function + Accumulator function. + + Examples + -------- + > var accumulator = {{alias}}(); + > var m = accumulator() + null + > m = accumulator( 2.0, 3.0 ) + ~33.33 + > m = accumulator( 5.0, 2.0 ) + ~91.67 + > m = accumulator( 5.0, NaN ) + ~91.67 + > m = accumulator() + ~91.67 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/types/index.d.ts new file mode 100644 index 000000000000..d95333c3d127 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/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 input values, the accumulator function returns an updated mean absolute percentage error. If not provided input values, the accumulator function returns the current mean absolute percentage error. +* +* ## Notes +* +* - If provided `NaN`, it simply ignores that input. +* +* @param f - input value +* @param a - input value +* @returns mean absolute percentage error or null +*/ +type accumulator = ( f?: number, a?: number ) => number | null; + +/** +* Returns an accumulator function which incrementally computes the mean absolute percentage error. +* +* @returns accumulator function +* +* @example +* var accumulator = incrnanmape(); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0, 3.0 ); +* // returns ~33.33 +* +* m = accumulator( NaN, 3.0 ); +* // returns ~33.33 +* +* m = accumulator( 2.0, NaN ); +* // returns ~33.33 +* +* m = accumulator( NaN, NaN ); +* // returns ~33.33 +* +* m = accumulator( 5.0, 2.0 ); +* // returns ~91.67 +* +* m = accumulator(); +* // returns ~91.67 +*/ +declare function incrnanmape(): accumulator; + + +// EXPORTS // + +export = incrnanmape; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/types/test.ts new file mode 100644 index 000000000000..504affcb43ec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/docs/types/test.ts @@ -0,0 +1,73 @@ +/* +* @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 incrnanmape = require( './index' ); + + +// TESTS // + +// The function returns an accumulator function... +{ + incrnanmape(); // $ExpectType accumulator +} + +// The compiler throws an error if the function is provided arguments... +{ + incrnanmape( '5' ); // $ExpectError + incrnanmape( 5 ); // $ExpectError + incrnanmape( true ); // $ExpectError + incrnanmape( false ); // $ExpectError + incrnanmape( null ); // $ExpectError + incrnanmape( undefined ); // $ExpectError + incrnanmape( [] ); // $ExpectError + incrnanmape( {} ); // $ExpectError + incrnanmape( ( x: number ): number => x ); // $ExpectError +} + +// The function returns an accumulator function which returns an accumulated result... +{ + const acc = incrnanmape(); + + acc(); // $ExpectType number | null + acc( 3.14, 2.0 ); // $ExpectType number | null + acc( NaN, 2.0 ); // $ExpectType number | null + acc( 3.14, NaN ); // $ExpectType number | null + acc( NaN, NaN ); // $ExpectType number | null + +} + +// The compiler throws an error if the returned accumulator function is provided invalid arguments... +{ + const acc = incrnanmape(); + + 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/nanmape/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmape/examples/index.js new file mode 100644 index 000000000000..6850aef8feab --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/examples/index.js @@ -0,0 +1,43 @@ +/** +* @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 incrnanmape = require( './../lib' ); + +var accumulator; +var err; +var v1; +var v2; +var i; + +// Initialize an accumulator: +accumulator = incrnanmape(); + +// For each simulated datum, update the mean absolute percentage error... +console.log( '\nValue\tValue\tMAPE\n' ); +for ( i = 0; i < 100; i++ ) { + v1 = ( randu() < 0.2 ) ? NaN : randu() * 100.0; + v2 = ( randu() < 0.2 ) ? NaN : randu() * 100.0; + err = accumulator( v1, v2 ); + if ( err !== null ) { + console.log( '%d\t%d\t%d', v1.toFixed( 3 ), v2.toFixed( 3 ), err.toFixed( 3 ) ); + } +} +console.log( '\nFinal MAPE: %d\n', accumulator() ); diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmape/lib/index.js new file mode 100644 index 000000000000..038f08ff28b9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/lib/index.js @@ -0,0 +1,54 @@ +/** +* @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 absolute percentage error incrementally, ignoring `NaN`. +* +* @module @stdlib/stats/incr/nanmape +* +* @example +* var incrnanmape = require( '@stdlib/stats/incr/nanmape' ); +* +* var accumulator = incrnanmape(); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0, 3.0 ); +* // returns ~33.33 +* +* m = accumulator( NaN, 3.0 ); +* // returns ~33.33 +* +* m = accumulator( 5.0, 2.0 ); +* // returns ~91.67 +* +* m = accumulator(); +* // returns ~91.67 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmape/lib/main.js new file mode 100644 index 000000000000..40d9d45ffff1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/lib/main.js @@ -0,0 +1,81 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var incrmape = require( '@stdlib/stats/incr/mape' ); + + +// MAIN // + +/** +* Returns an accumulator function which incrementally computes the mean absolute percentage error, ignoring `NaN` values. +* +* @returns {Function} accumulator function +* +* @example +* var accumulator = incrnanmape(); +* +* var m = accumulator(); +* // returns null +* +* m = accumulator( 2.0, 3.0 ); +* // returns ~33.33 +* +* m = accumulator( NaN, 3.0 ); +* // returns ~33.33 +* +* m = accumulator( 2.0, NaN ); +* // returns ~33.33 +* +* m = accumulator( 5.0, 2.0 ); +* // returns ~91.67 +* +* m = accumulator(); +* // returns ~91.67 +*/ +function incrnanmape() { + var acc = incrmape(); + return accumulator; + + /** + * If provided input values, the accumulator function returns an updated mean absolute percentage error. If not provided input values, the accumulator function returns the current mean absolute percentage error. + * + * @private + * @param {number} [f] - input value + * @param {number} [a] - input value + * @returns {(number|null)} mean absolute percentage error or null + */ + function accumulator( f, a ) { + if ( arguments.length === 0 ) { + return acc(); + } + if ( isnan( f ) || isnan( a ) ) { + return acc(); + } + return acc( f, a ); + } +} + + +// EXPORTS // + +module.exports = incrnanmape; diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/package.json b/lib/node_modules/@stdlib/stats/incr/nanmape/package.json new file mode 100644 index 000000000000..8cf605d7437e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/package.json @@ -0,0 +1,81 @@ +{ + "name": "@stdlib/stats/incr/nanmape", + "version": "0.0.0", + "description": "Compute the mean absolute percentage error (MAPE) incrementally.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "average", + "avg", + "mean", + "arithmetic mean", + "error", + "err", + "absolute", + "abs", + "percentage", + "percent", + "mape", + "deviation", + "difference", + "diff", + "delta", + "incremental", + "accumulator", + "time series", + "timeseries", + "demand", + "forecasting", + "forecast" + ] +} diff --git a/lib/node_modules/@stdlib/stats/incr/nanmape/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmape/test/test.js new file mode 100644 index 000000000000..2b7db6560496 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/incr/nanmape/test/test.js @@ -0,0 +1,155 @@ +/** +* @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 incrnanmape = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof incrnanmape, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an accumulator function', function test( t ) { + t.strictEqual( typeof incrnanmape(), 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the initial accumulated value is `null`', function test( t ) { + var acc = incrnanmape(); + t.strictEqual( acc(), null, 'returns expected value' ); + t.end(); +}); + +tape( 'the accumulator function incrementally computes the mean absolute percentage error', function test( t ) { + var expected; + var actual; + var delta; + var data; + var acc; + var sum; + var tol; + var N; + var x; + var y; + var i; + + data = [ + [ 2.0, 3.0 ], + [ 3.0, 1.0 ], + [ 2.0, 5.0 ], + [ 4.0, 4.0 ], + [ 3.0, 10.0 ], + [ 4.0, 5.0 ] + ]; + N = data.length; + + acc = incrnanmape(); + + sum = 0; + for ( i = 0; i < N; i++ ) { + x = data[ i ][ 0 ]; + y = data[ i ][ 1 ]; + sum += abs( ( y-x ) / y ); + expected = 100.0 * ( sum/(i+1) ); + actual = acc( x, y ); + if ( actual === expected ) { + t.strictEqual( actual, expected, 'returns expected value' ); + } else { + delta = abs( expected - actual ); + tol = 1.0 * EPS * abs( expected ); + t.strictEqual( delta <= tol, true, 'within tolerance. Actual: '+actual+'. Expected: '+expected+'. Delta: '+delta+'. Tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'if provided `NaN`, the value is ignored', function test( t ) { + var expected; + var actual; + var delta; + var data; + var tol; + var acc; + var i; + + acc = incrnanmape(); + + data = [ + [ 2.0, 3.0 ], + [ NaN, 3.0 ], + [ 2.0, NaN ], + [ NaN, NaN ], + [ 5.0, 2.0 ] + ]; + + expected = [ + 100.0 * ( 1.0/3.0 ), + 100.0 * ( 1.0/3.0 ), + 100.0 * ( 1.0/3.0 ), + 100.0 * ( 1.0/3.0 ), + 100.0 * ( ( (1.0/3.0) + 1.5 ) / 2.0 ) + ]; + + for ( i = 0; i < data.length; i++ ) { + actual = acc( data[ i ][ 0 ], data[ i ][ 1 ] ); + if ( actual === expected[ i ] ) { + t.strictEqual( actual, expected[ i ], 'returns expected value'); + } else { + delta = abs( actual - expected[ i ] ); + tol = 1.0 * EPS * abs( expected[ i ] ); + t.strictEqual( delta <= tol, true, 'within tolerance. Actual: '+actual+'. Expected: '+expected[ i ]+'. Delta: '+delta+'. Tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'if not provided an input value, the accumulator function returns the current mean absolute percentage error', function test( t ) { + var expected; + var actual; + var delta; + var data; + var acc; + var tol; + var i; + + data = [ + [ 2.0, 3.0 ], + [ 3.0, 5.0 ], + [ 10.0, 1.0 ] + ]; + acc = incrnanmape(); + for ( i = 0; i < data.length; i++ ) { + acc( data[ i ][ 0 ], data[ i ][ 1 ] ); + } + actual = acc(); + expected = 100.0 / 3.0 * ((1.0/3.0) + (2.0/5.0) + (9.0/1.0)); + delta = abs( expected - actual ); + tol = 1.0 * EPS * abs( expected ); + t.strictEqual( delta <= tol, true, 'within tolerance. Actual: '+actual+'. Expected: '+expected+'. Delta: '+delta+'. Tol: '+tol+'.' ); + t.end(); +});