From dcad1bc7519b274adb2649f9cf15a711a22b0e56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 05:03:09 +0000 Subject: [PATCH] Auto-generated commit --- .github/.keepalive | 1 + .github/workflows/publish.yml | 12 +- CONTRIBUTORS | 1 + package.json | 4 +- test/dist/test.js | 1014 +-------------------------------- 5 files changed, 18 insertions(+), 1014 deletions(-) create mode 100644 .github/.keepalive diff --git a/.github/.keepalive b/.github/.keepalive new file mode 100644 index 0000000..0f0e71b --- /dev/null +++ b/.github/.keepalive @@ -0,0 +1 @@ +2023-11-01T05:03:04.960Z diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b17435b..0037bdb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -182,7 +182,11 @@ jobs: fi # Trim leading and trailing whitespace: dep=$(echo "$dep" | xargs) - version="^$(npm view $dep version)" + version="$(npm view $dep version)" + if [[ -z "$version" ]]; then + continue + fi + version="^$version" jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp mv package.json.tmp package.json done @@ -192,7 +196,11 @@ jobs: fi # Trim leading and trailing whitespace: dep=$(echo "$dep" | xargs) - version="^$(npm view $dep version)" + version="$(npm view $dep version)" + if [[ -z "$version" ]]; then + continue + fi + version="^$version" jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp mv package.json.tmp package.json done diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 93c4bde..0dae4fe 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -37,3 +37,4 @@ Stephannie Jiménez Gacha Yernar Yergaziyev orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu +Robert Gislason diff --git a/package.json b/package.json index 698b6dd..4ee156d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/array-float64": "^0.1.0", + "@stdlib/array-float64": "^0.1.1", "@stdlib/assert-has-own-property": "^0.1.1", "@stdlib/assert-is-boolean": "^0.1.1", "@stdlib/assert-is-nan": "^0.1.1", @@ -52,7 +52,7 @@ "@stdlib/math-base-assert-is-positive-zero": "^0.1.1", "@stdlib/math-base-special-max": "^0.1.1", "@stdlib/math-base-special-roundn": "^0.1.0", - "@stdlib/math-base-special-sqrt": "^0.1.0", + "@stdlib/math-base-special-sqrt": "^0.1.1", "@stdlib/stats-base-dists-t-quantile": "^0.1.0", "@stdlib/string-format": "^0.1.1", "@stdlib/utils-define-read-only-accessor": "^0.1.1", diff --git a/test/dist/test.js b/test/dist/test.js index 60949fd..a8a9c60 100644 --- a/test/dist/test.js +++ b/test/dist/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2023 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. @@ -21,1019 +21,13 @@ // MODULES // var tape = require( 'tape' ); -var isnan = require( '@stdlib/assert-is-nan' ); -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert-is-function' ); -var rnorm = require( '@stdlib/random-base-normal' ); -var VENUS_SEMIDIAMETERS = require( '@stdlib/datasets-herndon-venus-semidiameters' ); -var incrmmean = require( '@stdlib/stats-incr-mmean' ); -var incrmstdev = require( '@stdlib/stats-incr-mstdev' ); -var incrmmin = require( '@stdlib/stats-incr-mmin' ); -var incrmmax = require( '@stdlib/stats-incr-mmax' ); -var incrmgrubbs = require( './../../dist' ); +var main = require( './../../dist' ); // TESTS // -tape( 'main export is a function', function test( t ) { +tape( 'main export is defined', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof incrmgrubbs, 'function', 'main export is a function' ); + t.strictEqual( main !== void 0, true, 'main export is defined' ); t.end(); }); - -tape( 'the function throws an error if provided a window size which is not a positive integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 0, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - 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() { - incrmgrubbs( value ); - }; - } -}); - -tape( 'the function throws an error if provided a window size which is less than 3', function test( t ) { - var values; - var i; - - values = [ - 1, - 2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrmgrubbs( value ); - }; - } -}); - -tape( 'the function throws an error if provided a window size which is not a positive integer (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 0, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - 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() { - incrmgrubbs( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a window size which is less than 3 (options)', function test( t ) { - var values; - var i; - - values = [ - 1, - 2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrmgrubbs( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - 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() { - incrmgrubbs( 20, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - -5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrmgrubbs( 20, { - 'alpha': value - }); - }; - } -}); - -tape( 'the function returns an accumulator function', function test( t ) { - t.strictEqual( typeof incrmgrubbs( 20 ), 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns an accumulator function (options)', function test( t ) { - t.strictEqual( typeof incrmgrubbs( 20, {} ), 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the accumulator function incrementally performs a moving Grubbs\' test for outliers (two-sided)', function test( t ) { - var stats; - var opts; - var acc; - var W; - var v; - var r; - var i; - - W = 20; - - opts = { - 'alpha': 0.00001 - }; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < 500; i++ ) { - v = rnorm( 10.0, 5.0 ); - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - r = acc( v ); - if ( r ) { - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( isBoolean( r.rejected ), true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, 'two-sided', 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the accumulator function incrementally performs a moving Grubbs\' test for outliers (max)', function test( t ) { - var stats; - var opts; - var acc; - var W; - var v; - var r; - var i; - - W = 20; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.00001, - 'alternative': 'max' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < 500; i++ ) { - v = rnorm( 10.0, 5.0 ); - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - r = acc( v ); - if ( r ) { - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( isBoolean( r.rejected ), true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the accumulator function incrementally performs a moving Grubbs\' test for outliers (min)', function test( t ) { - var stats; - var opts; - var acc; - var W; - var v; - var r; - var i; - - W = 20; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.00001, - 'alternative': 'min' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < 500; i++ ) { - v = rnorm( 10.0, 5.0 ); - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - r = acc( v ); - if ( r ) { - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( isBoolean( r.rejected ), true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the accumulator function can reject the null hypothesis (two-sided)', function test( t ) { - var stats; - var data; - var opts; - var acc; - var W; - var v; - var r; - var i; - - // 8 mass spectrometer measurements of a uranium isotope (see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) - data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; - - W = data.length; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.05, - 'alternative': 'two-sided' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < data.length; i++ ) { - v = data[ i ]; - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( r.rejected, true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function can reject the null hypothesis (max)', function test( t ) { - var stats; - var data; - var opts; - var acc; - var W; - var v; - var r; - var i; - - // 8 mass spectrometer measurements of a uranium isotope (see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) - data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; - - W = data.length; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.05, - 'alternative': 'max' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < data.length; i++ ) { - v = data[ i ]; - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( r.rejected, true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function can accept the null hypothesis (min)', function test( t ) { - var stats; - var data; - var opts; - var acc; - var W; - var v; - var r; - var i; - - // 8 mass spectrometer measurements of a uranium isotope (see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) - data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; - - W = data.length; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.05, - 'alternative': 'min' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < data.length; i++ ) { - v = data[ i ]; - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( r.rejected, false, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function can reject the null hypothesis (two-sided)', function test( t ) { - var stats; - var data; - var opts; - var acc; - var W; - var v; - var r; - var i; - - data = VENUS_SEMIDIAMETERS(); // eslint-disable-line new-cap - - W = data.length; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.05, - 'alternative': 'two-sided' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < data.length; i++ ) { - v = data[ i ]; - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( r.rejected, true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function can reject the null hypothesis (min)', function test( t ) { - var stats; - var data; - var opts; - var acc; - var W; - var v; - var r; - var i; - - data = VENUS_SEMIDIAMETERS(); // eslint-disable-line new-cap - - W = data.length; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.05, - 'alternative': 'min' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < data.length; i++ ) { - v = data[ i ]; - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( r.rejected, true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function can accept the null hypothesis (max)', function test( t ) { - var stats; - var data; - var opts; - var acc; - var W; - var v; - var r; - var i; - - data = VENUS_SEMIDIAMETERS(); // eslint-disable-line new-cap - - W = data.length; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.05, - 'alternative': 'max' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < data.length; i++ ) { - v = data[ i ]; - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( r.rejected, false, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'if not provided an input value, the accumulator function returns the current test results', function test( t ) { - var stats; - var opts; - var acc; - var W; - var v; - var r; - var i; - - W = 20; - - stats = { - 'mean': incrmmean( W ), - 'sd': incrmstdev( W ), - 'min': incrmmin( W ), - 'max': incrmmax( W ) - }; - opts = { - 'alpha': 0.10, - 'alternative': 'max' - }; - acc = incrmgrubbs( W, opts ); - for ( i = 0; i < 100; i++ ) { - v = rnorm( 10.0, 5.0 ); - stats.mean( v ); - stats.sd( v ); - stats.min( v ); - stats.max( v ); - acc( v ); - } - r = acc(); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.strictEqual( isBoolean( r.rejected ), true, 'returns expected value' ); - t.strictEqual( r.mean, stats.mean(), 'returns expected value' ); - t.strictEqual( r.sd, stats.sd(), 'returns expected value' ); - t.strictEqual( r.min, stats.min(), 'returns expected value' ); - t.strictEqual( r.max, stats.max(), 'returns expected value' ); - t.strictEqual( r.df, W-2, 'returns expected value' ); - t.strictEqual( r.alpha, opts.alpha, 'returns expected value' ); - t.strictEqual( r.alt, opts.alternative, 'returns expected value' ); - t.strictEqual( isNumber( r.statistic ), true, 'returns expected value' ); - t.strictEqual( isNumber( r.criticalValue ), true, 'returns expected value' ); - t.strictEqual( r.method, 'Grubbs\' Test', 'returns expected value' ); - t.end(); -}); - -tape( 'if provided a `NaN`, the accumulator function returns `NaN` for the test statistic', function test( t ) { - var acc; - var r; - var i; - - acc = incrmgrubbs( 3 ); - acc( rnorm( 10.0, 5.0 ) ); - acc( rnorm( 10.0, 5.0 ) ); - acc( rnorm( 10.0, 5.0 ) ); - - r = acc( NaN ); - t.strictEqual( isnan( r.statistic ), true, 'returns NaN' ); - t.strictEqual( isnan( r.mean ), true, 'returns NaN' ); - t.strictEqual( isnan( r.sd ), true, 'returns NaN' ); - t.strictEqual( isnan( r.min ), true, 'returns NaN' ); - t.strictEqual( isnan( r.max ), true, 'returns NaN' ); - - r = acc(); - t.strictEqual( isnan( r.statistic ), true, 'returns NaN' ); - t.strictEqual( isnan( r.mean ), true, 'returns NaN' ); - t.strictEqual( isnan( r.sd ), true, 'returns NaN' ); - t.strictEqual( isnan( r.min ), true, 'returns NaN' ); - t.strictEqual( isnan( r.max ), true, 'returns NaN' ); - - r = acc( rnorm( 10.0, 5.0 ) ); - t.strictEqual( isnan( r.statistic ), true, 'returns NaN' ); - t.strictEqual( isnan( r.mean ), true, 'returns NaN' ); - t.strictEqual( isnan( r.sd ), true, 'returns NaN' ); - t.strictEqual( isnan( r.min ), true, 'returns NaN' ); - t.strictEqual( isnan( r.max ), true, 'returns NaN' ); - - r = acc( rnorm( 10.0, 5.0 ) ); - t.strictEqual( isnan( r.statistic ), true, 'returns NaN' ); - t.strictEqual( isnan( r.mean ), true, 'returns NaN' ); - t.strictEqual( isnan( r.sd ), true, 'returns NaN' ); - t.strictEqual( isnan( r.min ), true, 'returns NaN' ); - t.strictEqual( isnan( r.max ), true, 'returns NaN' ); - - for ( i = 0; i < 100; i++ ) { - r = acc( rnorm( 10.0, 5.0 ) ); - t.strictEqual( isnan( r.statistic ), false, 'does not return NaN' ); - t.strictEqual( isnan( r.mean ), false, 'does not return NaN' ); - t.strictEqual( isnan( r.sd ), false, 'does not return NaN' ); - t.strictEqual( isnan( r.min ), false, 'does not return NaN' ); - t.strictEqual( isnan( r.max ), false, 'does not return NaN' ); - } - t.end(); -}); - -tape( 'if the accumulator function has not been provided any data, the accumulator function returns `null`', function test( t ) { - var acc = incrmgrubbs( 20 ); - t.strictEqual( acc(), null, 'returns expected value' ); - t.end(); -}); - -tape( 'if the accumulator function has not been provided an initial number of data points, the accumulator function returns `null`', function test( t ) { - var acc; - var r; - var i; - - acc = incrmgrubbs( 20 ); - for ( i = 0; i < 19; i++ ) { - r = acc( rnorm( 10.0, 5.0 ) ); - t.strictEqual( r, null, 'returns expected value' ); - } - r = acc( rnorm( 10.0, 5.0 ) ); - t.strictEqual( isPlainObject( r ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method (two-sided)', function test( t ) { - var opts; - var acc; - var r; - var i; - - opts = { - 'alternative': 'two-sided' - }; - acc = incrmgrubbs( 20, opts ); - for ( i = 0; i < 100; i++ ) { - r = acc( rnorm( 10.0, 5.0 ) ); - if ( r ) { - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - } - } - r = acc(); - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method (max)', function test( t ) { - var opts; - var acc; - var r; - var i; - - opts = { - 'alternative': 'max' - }; - acc = incrmgrubbs( 20, opts ); - for ( i = 0; i < 100; i++ ) { - r = acc( rnorm( 10.0, 5.0 ) ); - if ( r ) { - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - } - } - r = acc(); - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method (min)', function test( t ) { - var opts; - var acc; - var r; - var i; - - opts = { - 'alternative': 'min' - }; - acc = incrmgrubbs( 20, opts ); - for ( i = 0; i < 100; i++ ) { - r = acc( rnorm( 10.0, 5.0 ) ); - if ( r ) { - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - } - } - r = acc(); - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method (known outlier)', function test( t ) { - var opts; - var data; - var acc; - var r; - var i; - - // 8 mass spectrometer measurements of a uranium isotope (see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) - data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; - - opts = { - 'alternative': 'two-sided' - }; - acc = incrmgrubbs( data.length, opts ); - for ( i = 0; i < data.length; i++ ) { - r = acc( data[ i ] ); - if ( r ) { - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - } - } - r = acc(); - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print() ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method which supports specifying a `decision` option indicating whether to print the test decision', function test( t ) { - var popts; - var opts; - var data; - var acc; - var r; - var i; - - // 8 mass spectrometer measurements of a uranium isotope (see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) - data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; - - opts = { - 'alternative': 'two-sided' - }; - popts = { - 'decision': false - }; - acc = incrmgrubbs( 5, opts ); - for ( i = 0; i < data.length; i++ ) { - r = acc( data[ i ] ); - if ( r ) { - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - popts.decision = ( (i%2) === 0 ); - t.strictEqual( isString( r.print( popts ) ), true, 'returns expected value' ); - } - } - r = acc(); - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print( popts ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method which supports specifying a `digits` option indicating the number of digits to include after the decimal point for numeric values', function test( t ) { - var popts; - var opts; - var data; - var acc; - var r; - var i; - - // 8 mass spectrometer measurements of a uranium isotope (see Tietjen and Moore. 1972. "Some Grubbs-Type Statistics for the Detection of Several Outliers".) - data = [ 199.31, 199.53, 200.19, 200.82, 201.92, 201.95, 202.18, 245.57 ]; - - opts = { - 'alternative': 'two-sided' - }; - popts = { - 'digits': 10 - }; - acc = incrmgrubbs( 5, opts ); - for ( i = 0; i < data.length; i++ ) { - r = acc( data[ i ] ); - if ( r ) { - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print( popts ) ), true, 'returns expected value' ); - } - } - r = acc(); - t.strictEqual( isFunction( r.print ), true, 'returns expected value' ); - t.strictEqual( isString( r.print( popts ) ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the accumulator function returns a results object with a print method which throws if provided an options argument which is not an object', function test( t ) { - var values; - var acc; - var r; - var i; - - acc = incrmgrubbs( 20 ); - for ( i = 0; i < 100; i++ ) { - acc( rnorm( 10.0, 5.0 ) ); - } - r = acc(); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - 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() { - r.print( value ); - }; - } -}); - -tape( 'the accumulator function returns a results object with a print method which throws if provided a `digits` option which is not a positive integer', function test( t ) { - var values; - var acc; - var r; - var i; - - acc = incrmgrubbs( 20 ); - for ( i = 0; i < 100; i++ ) { - acc( rnorm( 10.0, 5.0 ) ); - } - r = acc(); - - values = [ - '5', - -5, - 0, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - 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() { - var opts = { - 'digits': value - }; - r.print( opts ); - }; - } -}); - -tape( 'the accumulator function returns a results object with a print method which throws if provided a `decision` option which is not a boolean', function test( t ) { - var values; - var acc; - var r; - var i; - - acc = incrmgrubbs( 20 ); - for ( i = 0; i < 100; i++ ) { - acc( rnorm( 10.0, 5.0 ) ); - } - r = acc(); - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - 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() { - var opts = { - 'decision': value - }; - r.print( opts ); - }; - } -});