@stdlib/stats-incr-mgrubbs 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -319,8 +319,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
319
319
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-incr-mgrubbs.svg
320
320
  [npm-url]: https://npmjs.org/package/@stdlib/stats-incr-mgrubbs
321
321
 
322
- [test-image]: https://github.com/stdlib-js/stats-incr-mgrubbs/actions/workflows/test.yml/badge.svg?branch=v0.2.1
323
- [test-url]: https://github.com/stdlib-js/stats-incr-mgrubbs/actions/workflows/test.yml?query=branch:v0.2.1
322
+ [test-image]: https://github.com/stdlib-js/stats-incr-mgrubbs/actions/workflows/test.yml/badge.svg?branch=v0.2.2
323
+ [test-url]: https://github.com/stdlib-js/stats-incr-mgrubbs/actions/workflows/test.yml?query=branch:v0.2.2
324
324
 
325
325
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-incr-mgrubbs/main.svg
326
326
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-incr-mgrubbs?branch=main
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/validate.js", "../lib/defaults.js", "../lib/minmax.js", "../lib/meanstdev.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar isnan = require( '@stdlib/assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination for validated options\n* @param {Options} options - function options\n* @param {number} [options.alpha] - significance level\n* @param {string} [options.alternative] - alternative hypothesis\n* @returns {(null|Error)} null or an error\n*\n* @example\n* var opts = {};\n*\n* var options = {\n* 'alpha': 0.05,\n* 'alernative': 'two-sided'\n* };\n*\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'alpha' ) ) {\n\t\topts.alpha = options.alpha;\n\t\tif ( !isNumber( opts.alpha ) || isnan( opts.alpha ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a number. Option: `%s`.', 'alpha', opts.alpha ) );\n\t\t}\n\t\tif ( opts.alpha < 0.0 || opts.alpha > 1.0 ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option must be on the interval: [0, 1]. Option: `%f`.', 'alpha', opts.alpha ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'alternative' ) ) {\n\t\topts.alternative = options.alternative;\n\t\tif ( !isString( opts.alternative ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'alternative', opts.alternative ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'alpha': 0.05,\n\t\t'alternative': 'two-sided',\n\t\t'digits': 4,\n\t\t'decision': true\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally computes moving minimum and maximum values.\n*\n* @private\n* @param {Collection} out - output array\n* @param {PositiveInteger} W - window size\n* @param {Collection} buf - data buffer\n* @returns {Function} accumulator function\n*\n* @example\n* var buf = [ 0.0, 0.0, 0.0 ];\n*\n* var accumulator = incrmminmax( [ 0.0, 0.0 ], 3, buf );\n*\n* var mm = accumulator( 2.0, 0 );\n* // returns [ 2.0, 2.0 ]\n*\n* buf[ 0 ] = 2.0;\n*\n* mm = accumulator( -5.0, 1 );\n* // returns [ -5.0, 2.0 ]\n*\n* buf[ 1 ] = -5.0;\n*\n* mm = accumulator( 3.0, 2 );\n* // returns [ -5.0, 3.0 ]\n*\n* buf[ 2 ] = 3.0;\n*\n* mm = accumulator( 5.0, 0 );\n* // returns [ -5.0, 5.0 ]\n*\n* buf[ 0 ] = 5.0;\n*/\nfunction incrmminmax( out, W, buf ) {\n\tvar min;\n\tvar max;\n\tvar N;\n\n\tmin = PINF;\n\tmax = NINF;\n\tN = 0;\n\n\treturn accumulator;\n\n\t/**\n\t* Updates accumulator state.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @param {NonNegativeInteger} i - buffer index\n\t* @returns {Collection} output array\n\t*/\n\tfunction accumulator( x, i ) {\n\t\tvar sgn;\n\t\tvar v;\n\t\tvar k;\n\n\t\t// Case: incoming value is NaN...\n\t\tif ( isnan( x ) ) {\n\t\t\tN = W; // explicitly set to avoid `N < W` branch\n\t\t\tmin = x;\n\t\t\tmax = x;\n\t\t}\n\t\t// Case: initial window...\n\t\telse if ( N < W ) {\n\t\t\tN += 1;\n\t\t\tif ( x < min || ( x === min && isNegativeZero( x ) ) ) {\n\t\t\t\tmin = x;\n\t\t\t}\n\t\t\tif ( x > max || ( x === max && isPositiveZero( x ) ) ) {\n\t\t\t\tmax = x;\n\t\t\t}\n\t\t}\n\t\t// Case: outgoing value is the current minimum or maximum and the new value is either greater than the minimum or less than the maximum, and, thus, we need to find new accumulated values among the current buffer values...\n\t\telse if (\n\t\t\t( buf[ i ] === min && x > min ) ||\n\t\t\t( buf[ i ] === max && x < max ) ||\n\t\t\tisnan( buf[ i ] )\n\t\t) {\n\t\t\tmin = x;\n\t\t\tmax = x;\n\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\tif ( k !== i ) {\n\t\t\t\t\tv = buf[ k ];\n\t\t\t\t\tif ( isnan( v ) ) {\n\t\t\t\t\t\tmin = v;\n\t\t\t\t\t\tmax = v;\n\t\t\t\t\t\tbreak; // no need to continue searching\n\t\t\t\t\t}\n\t\t\t\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\t\t\t\tmin = v;\n\t\t\t\t\t}\n\t\t\t\t\tif ( v > max || ( v === max && isPositiveZero( v ) ) ) {\n\t\t\t\t\t\tmax = v;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Case: incoming value is less than current minimum value...\n\t\telse if ( x < min ) {\n\t\t\tmin = x;\n\t\t}\n\t\t// Case: incoming value is greater than current maximum value...\n\t\telse if ( x > max ) {\n\t\t\tmax = x;\n\t\t}\n\t\t// Case: incoming value is zero, which means we need to be careful and correctly handle signed zeros...\n\t\telse if ( x === 0.0 ) {\n\t\t\tsgn = isNegativeZero( x );\n\t\t\tif ( x === min ) {\n\t\t\t\t// Case: outgoing value is the current minimum...\n\t\t\t\tif (\n\t\t\t\t\tbuf[ i ] === min &&\n\t\t\t\t\tisNegativeZero( buf[ i ] ) &&\n\t\t\t\t\tsgn === false\n\t\t\t\t) {\n\t\t\t\t\t// Because the outgoing and incoming are different signs (-,+), we need to search the buffer to see if it contains a negative zero. If so, the minimum value remains negative zero; otherwise, the minimum value is incoming value...\n\t\t\t\t\tmin = x;\n\t\t\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\t\t\tif ( k !== i && isNegativeZero( buf[ k ] ) ) {\n\t\t\t\t\t\t\tmin = buf[ k ];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if ( sgn ) {\n\t\t\t\t\t// Ensure minimum value has the correct sign:\n\t\t\t\t\tmin = x;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( x === max ) {\n\t\t\t\t// Case: outgoing value is the current maximum...\n\t\t\t\tif (\n\t\t\t\t\tbuf[ i ] === max &&\n\t\t\t\t\tisPositiveZero( buf[ i ] ) &&\n\t\t\t\t\tsgn\n\t\t\t\t) {\n\t\t\t\t\t// Because the outgoing and incoming are different signs (+,-), we need to search the buffer to see if it contains a positive zero. If so, the maximum value remains positive zero; otherwise, the maximum value is incoming value...\n\t\t\t\t\tmax = x;\n\t\t\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\t\t\tif ( k !== i && isPositiveZero( buf[ k ] ) ) {\n\t\t\t\t\t\t\tmax = buf[ k ];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if ( sgn === false ) {\n\t\t\t\t\t// Ensure maximum value has the correct sign:\n\t\t\t\t\tmax = x;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Case: updating existing window; however, the minimum and maximum values do not change so nothing to do...\n\n\t\tout[ 0 ] = min;\n\t\tout[ 1 ] = max;\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrmminmax;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally computes a moving arithmetic mean and corrected sample standard deviation.\n*\n* ## Method\n*\n* - Let \\\\(W\\\\) be a window of \\\\(N\\\\) elements over which we want to compute a corrected sample standard deviation.\n*\n* - We first recognize that the corrected sample standard deviation is defined as the square root of the unbiased sample variance. Accordingly, in order to derive an update equation for the corrected sample standard deviation, deriving an update equation for the unbiased sample variance is sufficient.\n*\n* - The difference between the unbiased sample variance in a window \\\\(W_i\\\\) and the unbiased sample variance in a window \\\\(W_{i+1})\\\\) is given by\n*\n* ```tex\n* \\Delta s^2 = s_{i+1}^2 - s_{i}^2\n* ```\n*\n* - If we multiply both sides by \\\\(N-1\\\\),\n*\n* ```tex\n* (N-1)(\\Delta s^2) = (N-1)s_{i+1}^2 - (N-1)s_{i}^2\n* ```\n*\n* - If we substitute the definition of the unbiased sample variance having the form\n*\n* ```tex\n* \\begin{align*}\n* s^2 &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} (x_i - \\bar{x})^2 \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} (x_i^2 - 2\\bar{x}x_i + \\bar{x}^2) \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - 2\\bar{x} \\sum_{i=1}^{N} x_i + \\sum_{i=1}^{N} \\bar{x}^2) \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - \\frac{2N\\bar{x}\\sum_{i=1}^{N} x_i}{N} + N\\bar{x}^2 \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - 2N\\bar{x}^2 + N\\bar{x}^2 \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - N\\bar{x}^2 \\biggr)\n* \\end{align*}\n* ```\n*\n* we return\n*\n* ```tex\n* (N-1)(\\Delta s^2) = \\biggl(\\sum_{k=1}^N x_k^2 - N\\bar{x}_{i+1}^2 \\biggr) - \\biggl(\\sum_{k=0}^{N-1} x_k^2 - N\\bar{x}_{i}^2 \\biggr)\n* ```\n*\n* - This can be further simplified by recognizing that subtracting the sums reduces to \\\\(x_N^2 - x_0^2\\\\); in which case,\n*\n* ```tex\n* \\begin{align*}\n* (N-1)(\\Delta s^2) &= x_N^2 - x_0^2 - N\\bar{x}_{i+1}^2 + N\\bar{x}_{i}^2 \\\\\n* &= x_N^2 - x_0^2 - N(\\bar{x}_{i+1}^2 - \\bar{x}_{i}^2) \\\\\n* &= x_N^2 - x_0^2 - N(\\bar{x}_{i+1} - \\bar{x}_{i})(\\bar{x}_{i+1} + \\bar{x}_{i})\n* \\end{align*}\n* ```\n*\n* - Recognizing that the difference of means can be expressed\n*\n* ```tex\n* \\bar{x}_{i+1} - \\bar{x}_i = \\frac{1}{N} \\biggl( \\sum_{k=1}^N x_k - \\sum_{k=0}^{N-1} x_k \\biggr) = \\frac{x_N - x_0}{N}\n* ```\n*\n* and substituting into the equation above\n*\n* ```tex\n* (N-1)(\\Delta s^2) = x_N^2 - x_0^2 - (x_N - x_0)(\\bar{x}_{i+1} + \\bar{x}_{i})\n* ```\n*\n* - Rearranging terms gives us the update equation\n*\n* ```tex\n* \\begin{align*}\n* (N-1)(\\Delta s^2) &= (x_N - x_0)(x_N + x_0) - (x_N - x_0)(\\bar{x}_{i+1} + \\bar{x}_{i})\n* &= (x_N - x_0)(x_N + x_0 - \\bar{x}_{i+1} - \\bar{x}_{i}) \\\\\n* &= (x_N - x_0)(x_N - \\bar{x}_{i+1} + x_0 - \\bar{x}_{i})\n* \\end{align*}\n* ```\n*\n* @private\n* @param {Collection} out - output array\n* @param {PositiveInteger} W - window size\n* @param {Collection} buf - data buffer\n* @returns {Function} accumulator function\n*\n* @example\n* var buf = [ 0.0, 0.0, 0.0 ];\n* var accumulator = incrmmeanstdev( [ 0.0, 0.0 ], 3, buf );\n*\n* var v = accumulator( 2.0, 0 );\n* // returns [ 2.0, 0.0 ]\n*\n* buf[ 0 ] = 2.0;\n*\n* v = accumulator( -5.0, 1 );\n* // returns [ -1.5, ~4.95 ]\n*\n* buf[ 1 ] = -5.0;\n*\n* v = accumulator( 3.0, 2 );\n* // returns [ 0.0, ~4.36 ]\n*\n* buf[ 2 ] = 3.0;\n*\n* v = accumulator( 5.0, 0 );\n* // returns [ 1.0, ~5.29 ]\n*\n* buf[ 0 ] = 5.0;\n*/\nfunction incrmmeanstdev( out, W, buf ) {\n\tvar delta;\n\tvar tmp;\n\tvar M2;\n\tvar mu;\n\tvar d1;\n\tvar d2;\n\tvar N;\n\tvar n;\n\n\tn = W - 1;\n\tM2 = 0.0;\n\tmu = 0.0;\n\tN = 0;\n\n\treturn accumulator;\n\n\t/**\n\t* Updates accumulator state.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @param {NonNegativeInteger} i - buffer index\n\t* @returns {ArrayLike} output array\n\t*/\n\tfunction accumulator( x, i ) {\n\t\tvar k;\n\t\tvar v;\n\n\t\t// Case: incoming value is NaN, the sliding second moment is automatically NaN...\n\t\tif ( isnan( x ) ) {\n\t\t\tN = W; // explicitly set to avoid `N < W` branch\n\t\t\tmu = NaN;\n\t\t\tM2 = NaN;\n\t\t}\n\t\t// Case: initial window...\n\t\telse if ( N < W ) {\n\t\t\tN += 1;\n\t\t\tdelta = x - mu;\n\t\t\tmu += delta / N;\n\t\t\tM2 += delta * (x - mu);\n\n\t\t\tout[ 0 ] = mu;\n\t\t\tif ( N === 1 ) {\n\t\t\t\tout[ 1 ] = 0.0;\n\t\t\t} else {\n\t\t\t\tout[ 1 ] = sqrt( M2/(N-1) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// Case: N = W = 1\n\t\telse if ( N === 1 ) {\n\t\t\tmu = x;\n\t\t\tM2 = 0.0;\n\t\t\tout[ 0 ] = x;\n\t\t\tout[ 1 ] = 0.0;\n\t\t\treturn out;\n\t\t}\n\t\t// Case: outgoing value is NaN, and, thus, we need to compute the accumulated values...\n\t\telse if ( isnan( buf[ i ] ) ) {\n\t\t\tN = 1;\n\t\t\tmu = x;\n\t\t\tM2 = 0.0;\n\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\tif ( k !== i ) {\n\t\t\t\t\tv = buf[ k ];\n\t\t\t\t\tif ( isnan( v ) ) {\n\t\t\t\t\t\tN = W; // explicitly set to avoid `N < W` branch\n\t\t\t\t\t\tmu = NaN;\n\t\t\t\t\t\tM2 = NaN;\n\t\t\t\t\t\tbreak; // second moment is automatically NaN, so no need to continue\n\t\t\t\t\t}\n\t\t\t\t\tN += 1;\n\t\t\t\t\tdelta = v - mu;\n\t\t\t\t\tmu += delta / N;\n\t\t\t\t\tM2 += delta * (v - mu);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Case: neither the current second moment nor the incoming value are NaN, so we need to update the accumulated values...\n\t\telse if ( isnan( M2 ) === false ) {\n\t\t\ttmp = buf[ i ];\n\t\t\tdelta = x - tmp;\n\t\t\td1 = tmp - mu;\n\t\t\tmu += delta / W;\n\t\t\td2 = x - mu;\n\t\t\tM2 += delta * (d1 + d2);\n\t\t}\n\t\t// Case: the current second moment is NaN, so nothing to do until the buffer no longer contains NaN values...\n\n\t\tout[ 0 ] = mu;\n\t\tout[ 1 ] = sqrt( M2/n );\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrmmeanstdev;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar setReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar max = require( '@stdlib/math-base-special-max' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\nvar roundn = require( '@stdlib/math-base-special-roundn' );\nvar format = require( '@stdlib/string-format' );\nvar tQuantile = require( '@stdlib/stats-base-dists-t-quantile' );\nvar Float64Array = require( '@stdlib/array-float64' );\nvar validate = require( './validate.js' );\nvar defaults = require( './defaults.js' );\nvar incrmminmax = require( './minmax.js' );\nvar incrmmeanstdev = require( './meanstdev.js' );\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally performs a moving Grubbs' test for detecting outliers.\n*\n* @param {PositiveInteger} W - window size\n* @param {Options} [options] - function options\n* @param {number} [options.alpha=0.05] - significance level\n* @param {string} [options.alternative='two-sided'] - alternative hypothesis ('two-sided', 'min', 'max')\n* @throws {TypeError} first argument must be a positive integer\n* @throws {RangeError} first argument must be greater than or equal to 3\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {RangeError} `alpha` option must be on the interval `[0,1]`\n* @returns {Function} accumulator function\n*\n* @example\n* var rnorm = require( '@stdlib/random-base-normal' );\n*\n* var accumulator;\n* var opts;\n* var i;\n*\n* accumulator = incrmgrubbs( 20, opts );\n*\n* for ( i = 0; i < 200; i++ ) {\n* res = accumulator( rnorm( 10.0, 5.0 ) );\n* }\n*/\nfunction incrmgrubbs( W ) {\n\tvar meanstdev;\n\tvar results;\n\tvar minmax;\n\tvar opts;\n\tvar err;\n\tvar buf;\n\tvar sig;\n\tvar mm;\n\tvar ms;\n\tvar tc;\n\tvar gc;\n\tvar df;\n\tvar N;\n\tvar G;\n\tvar i;\n\n\tif ( !isPositiveInteger( W ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Window size must be a positive integer. Value: `%s`.', W ) );\n\t}\n\tif ( W < 3 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Window size must be greater than or equal to 3. Value: `%s`.', W ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, arguments[ 1 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tbuf = new Float64Array( W );\n\tdf = W - 2;\n\tgc = 0.0;\n\tG = 0.0;\n\tN = 0;\n\ti = -1;\n\n\t// Compute the critical values:\n\tif ( opts.alternative === 'min' ) {\n\t\tsig = opts.alpha / W;\n\t} else if ( opts.alternative === 'max' ) {\n\t\tsig = opts.alpha / W;\n\t} else { // two-sided\n\t\tsig = opts.alpha / (2*W);\n\t}\n\ttc = tQuantile( 1.0-sig, df );\n\tgc = (W-1)*tc / sqrt( W*(df+(tc*tc)) );\n\n\t// Initialize statistics accumulators:\n\tmm = [ 0.0, 0.0 ];\n\tminmax = incrmminmax( mm, W, buf );\n\n\tms = [ 0.0, 0.0 ];\n\tmeanstdev = incrmmeanstdev( ms, W, buf );\n\n\t// Initialize the results object:\n\tresults = {};\n\tsetReadOnlyAccessor( results, 'rejected', getRejected );\n\tsetReadOnly( results, 'alpha', opts.alpha );\n\tsetReadOnly( results, 'criticalValue', gc );\n\tsetReadOnlyAccessor( results, 'statistic', getStatistic );\n\tsetReadOnly( results, 'df', df );\n\tsetReadOnlyAccessor( results, 'mean', getMean );\n\tsetReadOnlyAccessor( results, 'sd', getStDev );\n\tsetReadOnlyAccessor( results, 'min', getMin );\n\tsetReadOnlyAccessor( results, 'max', getMax );\n\tsetReadOnly( results, 'alt', opts.alternative );\n\tsetReadOnly( results, 'method', 'Grubbs\\' Test' );\n\tsetReadOnly( results, 'print', print );\n\n\treturn accumulator;\n\n\t/**\n\t* If provided a value, the accumulator function returns updated Grubbs' test results. If not provided a value, the accumulator function returns the current Grubbs' test results.\n\t*\n\t* @private\n\t* @param {number} [x] - new value\n\t* @returns {(Object|null)} test results or null\n\t*/\n\tfunction accumulator( x ) {\n\t\tvar md;\n\t\tif ( arguments.length === 0 ) {\n\t\t\tif ( N < W ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t\tN += 1;\n\n\t\t// Update the index for managing the circular buffer:\n\t\ti = (i+1) % W;\n\n\t\t// Update model statistics:\n\t\tmeanstdev( x, i );\n\t\tminmax( x, i );\n\n\t\t// Insert the value into the buffer:\n\t\tbuf[ i ] = x;\n\n\t\tif ( N < W ) {\n\t\t\treturn null;\n\t\t}\n\t\t// Compute the test statistic...\n\t\tif ( opts.alternative === 'min' ) {\n\t\t\tG = ( ms[0]-mm[0] ) / ms[ 1 ];\n\t\t} else if ( opts.alternative === 'max' ) {\n\t\t\tG = ( mm[1]-ms[0] ) / ms[ 1 ];\n\t\t} else { // two-sided\n\t\t\tmd = max( ms[0]-mm[0], mm[1]-ms[0] ); // maximum absolute deviation\n\t\t\tG = md / ms[ 1 ];\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t* Returns a `boolean` indicating whether the null hypothesis should be rejected.\n\t*\n\t* @private\n\t* @returns {boolean} boolean indicating whether the null hypothesis should be rejected\n\t*/\n\tfunction getRejected() {\n\t\treturn ( G > gc );\n\t}\n\n\t/**\n\t* Returns the test statistic.\n\t*\n\t* @private\n\t* @returns {number} test statistic\n\t*/\n\tfunction getStatistic() {\n\t\treturn G;\n\t}\n\n\t/**\n\t* Returns the sample mean.\n\t*\n\t* @private\n\t* @returns {number} sample mean\n\t*/\n\tfunction getMean() {\n\t\treturn ms[ 0 ];\n\t}\n\n\t/**\n\t* Returns the corrected sample standard deviation.\n\t*\n\t* @private\n\t* @returns {number} corrected sample standard deviation\n\t*/\n\tfunction getStDev() {\n\t\treturn ms[ 1 ];\n\t}\n\n\t/**\n\t* Returns the sample minimum.\n\t*\n\t* @private\n\t* @returns {number} sample minimum\n\t*/\n\tfunction getMin() {\n\t\treturn mm[ 0 ];\n\t}\n\n\t/**\n\t* Returns the sample maximum.\n\t*\n\t* @private\n\t* @returns {number} sample maximum\n\t*/\n\tfunction getMax() {\n\t\treturn mm[ 1 ];\n\t}\n\n\t/**\n\t* Pretty-print test results.\n\t*\n\t* @private\n\t* @param {Object} [options] - options object\n\t* @param {PositiveInteger} [options.digits=4] - number of digits after the decimal point\n\t* @param {boolean} [options.decision=true] - boolean indicating whether to print the test decision\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} formatted output\n\t*/\n\tfunction print( options ) {\n\t\tvar decision;\n\t\tvar digits;\n\t\tvar str;\n\n\t\tdigits = opts.digits;\n\t\tdecision = opts.decision;\n\t\tif ( arguments.length > 0 ) {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'digits' ) ) {\n\t\t\t\tif ( !isPositiveInteger( options.digits ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'digits', options.digits ) );\n\t\t\t\t}\n\t\t\t\tdigits = options.digits;\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'decision' ) ) {\n\t\t\t\tif ( !isBoolean( options.decision ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'decision', options.decision ) );\n\t\t\t\t}\n\t\t\t\tdecision = options.decision;\n\t\t\t}\n\t\t}\n\t\tstr = '';\n\t\tstr += results.method;\n\t\tstr += '\\n\\n';\n\t\tstr += 'Alternative hypothesis: ';\n\t\tif ( opts.alternative === 'max' ) {\n\t\t\tstr += 'The maximum value (' + mm[ 1 ] + ') is an outlier';\n\t\t} else if ( opts.alternative === 'min' ) {\n\t\t\tstr += 'The minimum value (' + mm[ 0 ] + ') is an outlier';\n\t\t} else { // two-sided\n\t\t\tstr += 'The ';\n\t\t\tif ( ms[0]-mm[0] > mm[1]-ms[0] ) {\n\t\t\t\tstr += 'minimum value (' + mm[ 0 ] + ')';\n\t\t\t} else {\n\t\t\t\tstr += 'maximum value (' + mm[ 1 ] + ')';\n\t\t\t}\n\t\t\tstr += ' is an outlier';\n\t\t}\n\t\tstr += '\\n\\n';\n\t\tstr += ' criticalValue: ' + roundn( gc, -digits ) + '\\n';\n\t\tstr += ' statistic: ' + roundn( G, -digits ) + '\\n';\n\t\tstr += ' df: ' + df + '\\n';\n\t\tstr += '\\n';\n\t\tif ( decision ) {\n\t\t\tstr += 'Test Decision: ';\n\t\t\tif ( G > gc ) {\n\t\t\t\tstr += 'Reject null in favor of alternative at ' + (opts.alpha*100.0) + '% significance level';\n\t\t\t} else {\n\t\t\t\tstr += 'Fail to reject null in favor of alternative at ' + (opts.alpha*100.0) + '% significance level';\n\t\t\t}\n\t\t\tstr += '\\n';\n\t\t}\n\t\treturn str;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrmgrubbs;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Moving Grubbs' test for outliers.\n*\n* @module @stdlib/stats-incr-mgrubbs\n*\n* @example\n* var rnorm = require( '@stdlib/random-base-normal' );\n* var incrmgrubbs = require( '@stdlib/stats-incr-mgrubbs' );\n*\n* var accumulator;\n* var res;\n* var i;\n*\n* accumulator = incrmgrubbs( 20 );\n*\n* for ( i = 0; i < 200; i++ ) {\n* res = accumulator( rnorm( 10.0, 5.0 ) );\n* }\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\nvar isnan = require( '@stdlib/assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination for validated options\n* @param {Options} options - function options\n* @param {number} [options.alpha] - significance level\n* @param {string} [options.alternative] - alternative hypothesis\n* @returns {(null|Error)} null or an error\n*\n* @example\n* var opts = {};\n*\n* var options = {\n* 'alpha': 0.05,\n* 'alternative': 'two-sided'\n* };\n*\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'alpha' ) ) {\n\t\topts.alpha = options.alpha;\n\t\tif ( !isNumber( opts.alpha ) || isnan( opts.alpha ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a number. Option: `%s`.', 'alpha', opts.alpha ) );\n\t\t}\n\t\tif ( opts.alpha < 0.0 || opts.alpha > 1.0 ) {\n\t\t\treturn new RangeError( format( 'invalid option. `%s` option must be on the interval: [0, 1]. Option: `%f`.', 'alpha', opts.alpha ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'alternative' ) ) {\n\t\topts.alternative = options.alternative;\n\t\tif ( !isString( opts.alternative ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'alternative', opts.alternative ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'alpha': 0.05,\n\t\t'alternative': 'two-sided',\n\t\t'digits': 4,\n\t\t'decision': true\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveZero = require( '@stdlib/math-base-assert-is-positive-zero' );\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally computes moving minimum and maximum values.\n*\n* @private\n* @param {Collection} out - output array\n* @param {PositiveInteger} W - window size\n* @param {Collection} buf - data buffer\n* @returns {Function} accumulator function\n*\n* @example\n* var buf = [ 0.0, 0.0, 0.0 ];\n*\n* var accumulator = incrmminmax( [ 0.0, 0.0 ], 3, buf );\n*\n* var mm = accumulator( 2.0, 0 );\n* // returns [ 2.0, 2.0 ]\n*\n* buf[ 0 ] = 2.0;\n*\n* mm = accumulator( -5.0, 1 );\n* // returns [ -5.0, 2.0 ]\n*\n* buf[ 1 ] = -5.0;\n*\n* mm = accumulator( 3.0, 2 );\n* // returns [ -5.0, 3.0 ]\n*\n* buf[ 2 ] = 3.0;\n*\n* mm = accumulator( 5.0, 0 );\n* // returns [ -5.0, 5.0 ]\n*\n* buf[ 0 ] = 5.0;\n*/\nfunction incrmminmax( out, W, buf ) {\n\tvar min;\n\tvar max;\n\tvar N;\n\n\tmin = PINF;\n\tmax = NINF;\n\tN = 0;\n\n\treturn accumulator;\n\n\t/**\n\t* Updates accumulator state.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @param {NonNegativeInteger} i - buffer index\n\t* @returns {Collection} output array\n\t*/\n\tfunction accumulator( x, i ) {\n\t\tvar sgn;\n\t\tvar v;\n\t\tvar k;\n\n\t\t// Case: incoming value is NaN...\n\t\tif ( isnan( x ) ) {\n\t\t\tN = W; // explicitly set to avoid `N < W` branch\n\t\t\tmin = x;\n\t\t\tmax = x;\n\t\t}\n\t\t// Case: initial window...\n\t\telse if ( N < W ) {\n\t\t\tN += 1;\n\t\t\tif ( x < min || ( x === min && isNegativeZero( x ) ) ) {\n\t\t\t\tmin = x;\n\t\t\t}\n\t\t\tif ( x > max || ( x === max && isPositiveZero( x ) ) ) {\n\t\t\t\tmax = x;\n\t\t\t}\n\t\t}\n\t\t// Case: outgoing value is the current minimum or maximum and the new value is either greater than the minimum or less than the maximum, and, thus, we need to find new accumulated values among the current buffer values...\n\t\telse if (\n\t\t\t( buf[ i ] === min && x > min ) ||\n\t\t\t( buf[ i ] === max && x < max ) ||\n\t\t\tisnan( buf[ i ] )\n\t\t) {\n\t\t\tmin = x;\n\t\t\tmax = x;\n\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\tif ( k !== i ) {\n\t\t\t\t\tv = buf[ k ];\n\t\t\t\t\tif ( isnan( v ) ) {\n\t\t\t\t\t\tmin = v;\n\t\t\t\t\t\tmax = v;\n\t\t\t\t\t\tbreak; // no need to continue searching\n\t\t\t\t\t}\n\t\t\t\t\tif ( v < min || ( v === min && isNegativeZero( v ) ) ) {\n\t\t\t\t\t\tmin = v;\n\t\t\t\t\t}\n\t\t\t\t\tif ( v > max || ( v === max && isPositiveZero( v ) ) ) {\n\t\t\t\t\t\tmax = v;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Case: incoming value is less than current minimum value...\n\t\telse if ( x < min ) {\n\t\t\tmin = x;\n\t\t}\n\t\t// Case: incoming value is greater than current maximum value...\n\t\telse if ( x > max ) {\n\t\t\tmax = x;\n\t\t}\n\t\t// Case: incoming value is zero, which means we need to be careful and correctly handle signed zeros...\n\t\telse if ( x === 0.0 ) {\n\t\t\tsgn = isNegativeZero( x );\n\t\t\tif ( x === min ) {\n\t\t\t\t// Case: outgoing value is the current minimum...\n\t\t\t\tif (\n\t\t\t\t\tbuf[ i ] === min &&\n\t\t\t\t\tisNegativeZero( buf[ i ] ) &&\n\t\t\t\t\tsgn === false\n\t\t\t\t) {\n\t\t\t\t\t// Because the outgoing and incoming are different signs (-,+), we need to search the buffer to see if it contains a negative zero. If so, the minimum value remains negative zero; otherwise, the minimum value is incoming value...\n\t\t\t\t\tmin = x;\n\t\t\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\t\t\tif ( k !== i && isNegativeZero( buf[ k ] ) ) {\n\t\t\t\t\t\t\tmin = buf[ k ];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if ( sgn ) {\n\t\t\t\t\t// Ensure minimum value has the correct sign:\n\t\t\t\t\tmin = x;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( x === max ) {\n\t\t\t\t// Case: outgoing value is the current maximum...\n\t\t\t\tif (\n\t\t\t\t\tbuf[ i ] === max &&\n\t\t\t\t\tisPositiveZero( buf[ i ] ) &&\n\t\t\t\t\tsgn\n\t\t\t\t) {\n\t\t\t\t\t// Because the outgoing and incoming are different signs (+,-), we need to search the buffer to see if it contains a positive zero. If so, the maximum value remains positive zero; otherwise, the maximum value is incoming value...\n\t\t\t\t\tmax = x;\n\t\t\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\t\t\tif ( k !== i && isPositiveZero( buf[ k ] ) ) {\n\t\t\t\t\t\t\tmax = buf[ k ];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if ( sgn === false ) {\n\t\t\t\t\t// Ensure maximum value has the correct sign:\n\t\t\t\t\tmax = x;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Case: updating existing window; however, the minimum and maximum values do not change so nothing to do...\n\n\t\tout[ 0 ] = min;\n\t\tout[ 1 ] = max;\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrmminmax;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally computes a moving arithmetic mean and corrected sample standard deviation.\n*\n* ## Method\n*\n* - Let \\\\(W\\\\) be a window of \\\\(N\\\\) elements over which we want to compute a corrected sample standard deviation.\n*\n* - We first recognize that the corrected sample standard deviation is defined as the square root of the unbiased sample variance. Accordingly, in order to derive an update equation for the corrected sample standard deviation, deriving an update equation for the unbiased sample variance is sufficient.\n*\n* - The difference between the unbiased sample variance in a window \\\\(W_i\\\\) and the unbiased sample variance in a window \\\\(W_{i+1})\\\\) is given by\n*\n* ```tex\n* \\Delta s^2 = s_{i+1}^2 - s_{i}^2\n* ```\n*\n* - If we multiply both sides by \\\\(N-1\\\\),\n*\n* ```tex\n* (N-1)(\\Delta s^2) = (N-1)s_{i+1}^2 - (N-1)s_{i}^2\n* ```\n*\n* - If we substitute the definition of the unbiased sample variance having the form\n*\n* ```tex\n* \\begin{align*}\n* s^2 &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} (x_i - \\bar{x})^2 \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} (x_i^2 - 2\\bar{x}x_i + \\bar{x}^2) \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - 2\\bar{x} \\sum_{i=1}^{N} x_i + \\sum_{i=1}^{N} \\bar{x}^2) \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - \\frac{2N\\bar{x}\\sum_{i=1}^{N} x_i}{N} + N\\bar{x}^2 \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - 2N\\bar{x}^2 + N\\bar{x}^2 \\biggr) \\\\\n* &= \\frac{1}{N-1} \\biggl( \\sum_{i=1}^{N} x_i^2 - N\\bar{x}^2 \\biggr)\n* \\end{align*}\n* ```\n*\n* we return\n*\n* ```tex\n* (N-1)(\\Delta s^2) = \\biggl(\\sum_{k=1}^N x_k^2 - N\\bar{x}_{i+1}^2 \\biggr) - \\biggl(\\sum_{k=0}^{N-1} x_k^2 - N\\bar{x}_{i}^2 \\biggr)\n* ```\n*\n* - This can be further simplified by recognizing that subtracting the sums reduces to \\\\(x_N^2 - x_0^2\\\\); in which case,\n*\n* ```tex\n* \\begin{align*}\n* (N-1)(\\Delta s^2) &= x_N^2 - x_0^2 - N\\bar{x}_{i+1}^2 + N\\bar{x}_{i}^2 \\\\\n* &= x_N^2 - x_0^2 - N(\\bar{x}_{i+1}^2 - \\bar{x}_{i}^2) \\\\\n* &= x_N^2 - x_0^2 - N(\\bar{x}_{i+1} - \\bar{x}_{i})(\\bar{x}_{i+1} + \\bar{x}_{i})\n* \\end{align*}\n* ```\n*\n* - Recognizing that the difference of means can be expressed\n*\n* ```tex\n* \\bar{x}_{i+1} - \\bar{x}_i = \\frac{1}{N} \\biggl( \\sum_{k=1}^N x_k - \\sum_{k=0}^{N-1} x_k \\biggr) = \\frac{x_N - x_0}{N}\n* ```\n*\n* and substituting into the equation above\n*\n* ```tex\n* (N-1)(\\Delta s^2) = x_N^2 - x_0^2 - (x_N - x_0)(\\bar{x}_{i+1} + \\bar{x}_{i})\n* ```\n*\n* - Rearranging terms gives us the update equation\n*\n* ```tex\n* \\begin{align*}\n* (N-1)(\\Delta s^2) &= (x_N - x_0)(x_N + x_0) - (x_N - x_0)(\\bar{x}_{i+1} + \\bar{x}_{i})\n* &= (x_N - x_0)(x_N + x_0 - \\bar{x}_{i+1} - \\bar{x}_{i}) \\\\\n* &= (x_N - x_0)(x_N - \\bar{x}_{i+1} + x_0 - \\bar{x}_{i})\n* \\end{align*}\n* ```\n*\n* @private\n* @param {Collection} out - output array\n* @param {PositiveInteger} W - window size\n* @param {Collection} buf - data buffer\n* @returns {Function} accumulator function\n*\n* @example\n* var buf = [ 0.0, 0.0, 0.0 ];\n* var accumulator = incrmmeanstdev( [ 0.0, 0.0 ], 3, buf );\n*\n* var v = accumulator( 2.0, 0 );\n* // returns [ 2.0, 0.0 ]\n*\n* buf[ 0 ] = 2.0;\n*\n* v = accumulator( -5.0, 1 );\n* // returns [ -1.5, ~4.95 ]\n*\n* buf[ 1 ] = -5.0;\n*\n* v = accumulator( 3.0, 2 );\n* // returns [ 0.0, ~4.36 ]\n*\n* buf[ 2 ] = 3.0;\n*\n* v = accumulator( 5.0, 0 );\n* // returns [ 1.0, ~5.29 ]\n*\n* buf[ 0 ] = 5.0;\n*/\nfunction incrmmeanstdev( out, W, buf ) {\n\tvar delta;\n\tvar tmp;\n\tvar M2;\n\tvar mu;\n\tvar d1;\n\tvar d2;\n\tvar N;\n\tvar n;\n\n\tn = W - 1;\n\tM2 = 0.0;\n\tmu = 0.0;\n\tN = 0;\n\n\treturn accumulator;\n\n\t/**\n\t* Updates accumulator state.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @param {NonNegativeInteger} i - buffer index\n\t* @returns {ArrayLike} output array\n\t*/\n\tfunction accumulator( x, i ) {\n\t\tvar k;\n\t\tvar v;\n\n\t\t// Case: incoming value is NaN, the sliding second moment is automatically NaN...\n\t\tif ( isnan( x ) ) {\n\t\t\tN = W; // explicitly set to avoid `N < W` branch\n\t\t\tmu = NaN;\n\t\t\tM2 = NaN;\n\t\t}\n\t\t// Case: initial window...\n\t\telse if ( N < W ) {\n\t\t\tN += 1;\n\t\t\tdelta = x - mu;\n\t\t\tmu += delta / N;\n\t\t\tM2 += delta * (x - mu);\n\n\t\t\tout[ 0 ] = mu;\n\t\t\tif ( N === 1 ) {\n\t\t\t\tout[ 1 ] = 0.0;\n\t\t\t} else {\n\t\t\t\tout[ 1 ] = sqrt( M2/(N-1) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// Case: N = W = 1\n\t\telse if ( N === 1 ) {\n\t\t\tmu = x;\n\t\t\tM2 = 0.0;\n\t\t\tout[ 0 ] = x;\n\t\t\tout[ 1 ] = 0.0;\n\t\t\treturn out;\n\t\t}\n\t\t// Case: outgoing value is NaN, and, thus, we need to compute the accumulated values...\n\t\telse if ( isnan( buf[ i ] ) ) {\n\t\t\tN = 1;\n\t\t\tmu = x;\n\t\t\tM2 = 0.0;\n\t\t\tfor ( k = 0; k < W; k++ ) {\n\t\t\t\tif ( k !== i ) {\n\t\t\t\t\tv = buf[ k ];\n\t\t\t\t\tif ( isnan( v ) ) {\n\t\t\t\t\t\tN = W; // explicitly set to avoid `N < W` branch\n\t\t\t\t\t\tmu = NaN;\n\t\t\t\t\t\tM2 = NaN;\n\t\t\t\t\t\tbreak; // second moment is automatically NaN, so no need to continue\n\t\t\t\t\t}\n\t\t\t\t\tN += 1;\n\t\t\t\t\tdelta = v - mu;\n\t\t\t\t\tmu += delta / N;\n\t\t\t\t\tM2 += delta * (v - mu);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Case: neither the current second moment nor the incoming value are NaN, so we need to update the accumulated values...\n\t\telse if ( isnan( M2 ) === false ) {\n\t\t\ttmp = buf[ i ];\n\t\t\tdelta = x - tmp;\n\t\t\td1 = tmp - mu;\n\t\t\tmu += delta / W;\n\t\t\td2 = x - mu;\n\t\t\tM2 += delta * (d1 + d2);\n\t\t}\n\t\t// Case: the current second moment is NaN, so nothing to do until the buffer no longer contains NaN values...\n\n\t\tout[ 0 ] = mu;\n\t\tout[ 1 ] = sqrt( M2/n );\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrmmeanstdev;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar setReadOnly = require( '@stdlib/utils-define-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-read-only-accessor' );\nvar max = require( '@stdlib/math-base-special-max' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\nvar roundn = require( '@stdlib/math-base-special-roundn' );\nvar format = require( '@stdlib/string-format' );\nvar tQuantile = require( '@stdlib/stats-base-dists-t-quantile' );\nvar Float64Array = require( '@stdlib/array-float64' );\nvar validate = require( './validate.js' );\nvar defaults = require( './defaults.js' );\nvar incrmminmax = require( './minmax.js' );\nvar incrmmeanstdev = require( './meanstdev.js' );\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally performs a moving Grubbs' test for detecting outliers.\n*\n* @param {PositiveInteger} W - window size\n* @param {Options} [options] - function options\n* @param {number} [options.alpha=0.05] - significance level\n* @param {string} [options.alternative='two-sided'] - alternative hypothesis ('two-sided', 'min', 'max')\n* @throws {TypeError} first argument must be a positive integer\n* @throws {RangeError} first argument must be greater than or equal to 3\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {RangeError} `alpha` option must be on the interval `[0,1]`\n* @returns {Function} accumulator function\n*\n* @example\n* var rnorm = require( '@stdlib/random-base-normal' );\n*\n* var accumulator;\n* var opts;\n* var i;\n*\n* accumulator = incrmgrubbs( 20, opts );\n*\n* for ( i = 0; i < 200; i++ ) {\n* res = accumulator( rnorm( 10.0, 5.0 ) );\n* }\n*/\nfunction incrmgrubbs( W ) {\n\tvar meanstdev;\n\tvar results;\n\tvar minmax;\n\tvar opts;\n\tvar err;\n\tvar buf;\n\tvar sig;\n\tvar mm;\n\tvar ms;\n\tvar tc;\n\tvar gc;\n\tvar df;\n\tvar N;\n\tvar G;\n\tvar i;\n\n\tif ( !isPositiveInteger( W ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Window size must be a positive integer. Value: `%s`.', W ) );\n\t}\n\tif ( W < 3 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Window size must be greater than or equal to 3. Value: `%s`.', W ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, arguments[ 1 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tbuf = new Float64Array( W );\n\tdf = W - 2;\n\tgc = 0.0;\n\tG = 0.0;\n\tN = 0;\n\ti = -1;\n\n\t// Compute the critical values:\n\tif ( opts.alternative === 'min' ) {\n\t\tsig = opts.alpha / W;\n\t} else if ( opts.alternative === 'max' ) {\n\t\tsig = opts.alpha / W;\n\t} else { // two-sided\n\t\tsig = opts.alpha / (2*W);\n\t}\n\ttc = tQuantile( 1.0-sig, df );\n\tgc = (W-1)*tc / sqrt( W*(df+(tc*tc)) );\n\n\t// Initialize statistics accumulators:\n\tmm = [ 0.0, 0.0 ];\n\tminmax = incrmminmax( mm, W, buf );\n\n\tms = [ 0.0, 0.0 ];\n\tmeanstdev = incrmmeanstdev( ms, W, buf );\n\n\t// Initialize the results object:\n\tresults = {};\n\tsetReadOnlyAccessor( results, 'rejected', getRejected );\n\tsetReadOnly( results, 'alpha', opts.alpha );\n\tsetReadOnly( results, 'criticalValue', gc );\n\tsetReadOnlyAccessor( results, 'statistic', getStatistic );\n\tsetReadOnly( results, 'df', df );\n\tsetReadOnlyAccessor( results, 'mean', getMean );\n\tsetReadOnlyAccessor( results, 'sd', getStDev );\n\tsetReadOnlyAccessor( results, 'min', getMin );\n\tsetReadOnlyAccessor( results, 'max', getMax );\n\tsetReadOnly( results, 'alt', opts.alternative );\n\tsetReadOnly( results, 'method', 'Grubbs\\' Test' );\n\tsetReadOnly( results, 'print', print );\n\n\treturn accumulator;\n\n\t/**\n\t* If provided a value, the accumulator function returns updated Grubbs' test results. If not provided a value, the accumulator function returns the current Grubbs' test results.\n\t*\n\t* @private\n\t* @param {number} [x] - new value\n\t* @returns {(Object|null)} test results or null\n\t*/\n\tfunction accumulator( x ) {\n\t\tvar md;\n\t\tif ( arguments.length === 0 ) {\n\t\t\tif ( N < W ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn results;\n\t\t}\n\t\tN += 1;\n\n\t\t// Update the index for managing the circular buffer:\n\t\ti = (i+1) % W;\n\n\t\t// Update model statistics:\n\t\tmeanstdev( x, i );\n\t\tminmax( x, i );\n\n\t\t// Insert the value into the buffer:\n\t\tbuf[ i ] = x;\n\n\t\tif ( N < W ) {\n\t\t\treturn null;\n\t\t}\n\t\t// Compute the test statistic...\n\t\tif ( opts.alternative === 'min' ) {\n\t\t\tG = ( ms[0]-mm[0] ) / ms[ 1 ];\n\t\t} else if ( opts.alternative === 'max' ) {\n\t\t\tG = ( mm[1]-ms[0] ) / ms[ 1 ];\n\t\t} else { // two-sided\n\t\t\tmd = max( ms[0]-mm[0], mm[1]-ms[0] ); // maximum absolute deviation\n\t\t\tG = md / ms[ 1 ];\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t* Returns a `boolean` indicating whether the null hypothesis should be rejected.\n\t*\n\t* @private\n\t* @returns {boolean} boolean indicating whether the null hypothesis should be rejected\n\t*/\n\tfunction getRejected() {\n\t\treturn ( G > gc );\n\t}\n\n\t/**\n\t* Returns the test statistic.\n\t*\n\t* @private\n\t* @returns {number} test statistic\n\t*/\n\tfunction getStatistic() {\n\t\treturn G;\n\t}\n\n\t/**\n\t* Returns the sample mean.\n\t*\n\t* @private\n\t* @returns {number} sample mean\n\t*/\n\tfunction getMean() {\n\t\treturn ms[ 0 ];\n\t}\n\n\t/**\n\t* Returns the corrected sample standard deviation.\n\t*\n\t* @private\n\t* @returns {number} corrected sample standard deviation\n\t*/\n\tfunction getStDev() {\n\t\treturn ms[ 1 ];\n\t}\n\n\t/**\n\t* Returns the sample minimum.\n\t*\n\t* @private\n\t* @returns {number} sample minimum\n\t*/\n\tfunction getMin() {\n\t\treturn mm[ 0 ];\n\t}\n\n\t/**\n\t* Returns the sample maximum.\n\t*\n\t* @private\n\t* @returns {number} sample maximum\n\t*/\n\tfunction getMax() {\n\t\treturn mm[ 1 ];\n\t}\n\n\t/**\n\t* Pretty-print test results.\n\t*\n\t* @private\n\t* @param {Object} [options] - options object\n\t* @param {PositiveInteger} [options.digits=4] - number of digits after the decimal point\n\t* @param {boolean} [options.decision=true] - boolean indicating whether to print the test decision\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {string} formatted output\n\t*/\n\tfunction print( options ) {\n\t\tvar decision;\n\t\tvar digits;\n\t\tvar str;\n\n\t\tdigits = opts.digits;\n\t\tdecision = opts.decision;\n\t\tif ( arguments.length > 0 ) {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'digits' ) ) {\n\t\t\t\tif ( !isPositiveInteger( options.digits ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'digits', options.digits ) );\n\t\t\t\t}\n\t\t\t\tdigits = options.digits;\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'decision' ) ) {\n\t\t\t\tif ( !isBoolean( options.decision ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'decision', options.decision ) );\n\t\t\t\t}\n\t\t\t\tdecision = options.decision;\n\t\t\t}\n\t\t}\n\t\tstr = '';\n\t\tstr += results.method;\n\t\tstr += '\\n\\n';\n\t\tstr += 'Alternative hypothesis: ';\n\t\tif ( opts.alternative === 'max' ) {\n\t\t\tstr += 'The maximum value (' + mm[ 1 ] + ') is an outlier';\n\t\t} else if ( opts.alternative === 'min' ) {\n\t\t\tstr += 'The minimum value (' + mm[ 0 ] + ') is an outlier';\n\t\t} else { // two-sided\n\t\t\tstr += 'The ';\n\t\t\tif ( ms[0]-mm[0] > mm[1]-ms[0] ) {\n\t\t\t\tstr += 'minimum value (' + mm[ 0 ] + ')';\n\t\t\t} else {\n\t\t\t\tstr += 'maximum value (' + mm[ 1 ] + ')';\n\t\t\t}\n\t\t\tstr += ' is an outlier';\n\t\t}\n\t\tstr += '\\n\\n';\n\t\tstr += ' criticalValue: ' + roundn( gc, -digits ) + '\\n';\n\t\tstr += ' statistic: ' + roundn( G, -digits ) + '\\n';\n\t\tstr += ' df: ' + df + '\\n';\n\t\tstr += '\\n';\n\t\tif ( decision ) {\n\t\t\tstr += 'Test Decision: ';\n\t\t\tif ( G > gc ) {\n\t\t\t\tstr += 'Reject null in favor of alternative at ' + (opts.alpha*100.0) + '% significance level';\n\t\t\t} else {\n\t\t\t\tstr += 'Fail to reject null in favor of alternative at ' + (opts.alpha*100.0) + '% significance level';\n\t\t\t}\n\t\t\tstr += '\\n';\n\t\t}\n\t\treturn str;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrmgrubbs;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Moving Grubbs' test for outliers.\n*\n* @module @stdlib/stats-incr-mgrubbs\n*\n* @example\n* var rnorm = require( '@stdlib/random-base-normal' );\n* var incrmgrubbs = require( '@stdlib/stats-incr-mgrubbs' );\n*\n* var accumulator;\n* var res;\n* var i;\n*\n* accumulator = incrmgrubbs( 20 );\n*\n* for ( i = 0; i < 200; i++ ) {\n* res = accumulator( rnorm( 10.0, 5.0 ) );\n* }\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
5
  "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,iCAAkC,EACxDC,EAAW,QAAS,gCAAiC,EACrDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,GAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAC1CC,GAAQ,QAAS,uBAAwB,EA4B7C,SAASC,GAAUC,EAAMC,EAAU,CAClC,GAAK,CAACP,EAAUO,CAAQ,EACvB,OAAO,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE/G,GAAKR,EAAYQ,EAAS,OAAQ,EAAI,CAErC,GADAD,EAAK,MAAQC,EAAQ,MAChB,CAACN,EAAUK,EAAK,KAAM,GAAKF,GAAOE,EAAK,KAAM,EACjD,OAAO,IAAI,UAAWH,EAAQ,8DAA+D,QAASG,EAAK,KAAM,CAAE,EAEpH,GAAKA,EAAK,MAAQ,GAAOA,EAAK,MAAQ,EACrC,OAAO,IAAI,WAAYH,EAAQ,6EAA8E,QAASG,EAAK,KAAM,CAAE,CAErI,CACA,OAAKP,EAAYQ,EAAS,aAAc,IACvCD,EAAK,YAAcC,EAAQ,YACtB,CAACL,GAAUI,EAAK,WAAY,GACzB,IAAI,UAAWH,EAAQ,8DAA+D,cAAeG,EAAK,WAAY,CAAE,EAG1H,IACR,CAKAR,EAAO,QAAUO,KChFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAgCA,SAASC,IAAW,CACnB,MAAO,CACN,MAAS,IACT,YAAe,YACf,OAAU,EACV,SAAY,EACb,CACD,CAKAD,EAAO,QAAUC,KC5CjB,IAAAC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IE,EAASF,EAAQ,MAClB,CACA,GAAK3C,EAAY2C,EAAS,UAAW,EAAI,CACxC,GAAK,CAACxC,GAAWwC,EAAQ,QAAS,EACjC,MAAM,IAAI,UAAWlC,EAAQ,+DAAgE,WAAYkC,EAAQ,QAAS,CAAE,EAE7HC,EAAWD,EAAQ,QACpB,CACD,CACA,OAAAG,EAAM,GACNA,GAAO3B,EAAQ,OACf2B,GAAO,OACPA,GAAO,2BACFzB,EAAK,cAAgB,MACzByB,GAAO,sBAAwBrB,EAAI,CAAE,EAAI,kBAC9BJ,EAAK,cAAgB,MAChCyB,GAAO,sBAAwBrB,EAAI,CAAE,EAAI,mBAEzCqB,GAAO,OACFpB,EAAG,CAAC,EAAED,EAAG,CAAC,EAAIA,EAAG,CAAC,EAAEC,EAAG,CAAC,EAC5BoB,GAAO,kBAAoBrB,EAAI,CAAE,EAAI,IAErCqB,GAAO,kBAAoBrB,EAAI,CAAE,EAAI,IAEtCqB,GAAO,kBAERA,GAAO,OACPA,GAAO,sBAAwBtC,EAAQoB,EAAI,CAACiB,CAAO,EAAI,KACvDC,GAAO,kBAAoBtC,EAAQuB,EAAG,CAACc,CAAO,EAAI,KAClDC,GAAO,WAAajB,EAAK,KACzBiB,GAAO,KACFF,IACJE,GAAO,kBACFf,EAAIH,EACRkB,GAAO,0CAA6CzB,EAAK,MAAM,IAAS,uBAExEyB,GAAO,kDAAqDzB,EAAK,MAAM,IAAS,uBAEjFyB,GAAO,MAEDA,CACR,CACD,CAKA/C,EAAO,QAAUiB,KClRjB,IAAI+B,GAAO,IAKX,OAAO,QAAUA",
6
6
  "names": ["require_validate", "__commonJSMin", "exports", "module", "hasOwnProp", "isObject", "isNumber", "isString", "format", "isnan", "validate", "opts", "options", "require_defaults", "__commonJSMin", "exports", "module", "defaults", "require_minmax", "__commonJSMin", "exports", "module", "isPositiveZero", "isNegativeZero", "isnan", "PINF", "NINF", "incrmminmax", "out", "W", "buf", "min", "max", "N", "accumulator", "x", "i", "sgn", "v", "k", "require_meanstdev", "__commonJSMin", "exports", "module", "isnan", "sqrt", "incrmmeanstdev", "out", "W", "buf", "delta", "tmp", "M2", "mu", "d1", "d2", "N", "n", "accumulator", "x", "i", "k", "v", "require_main", "__commonJSMin", "exports", "module", "hasOwnProp", "isObject", "isPositiveInteger", "isBoolean", "setReadOnly", "setReadOnlyAccessor", "max", "sqrt", "roundn", "format", "tQuantile", "Float64Array", "validate", "defaults", "incrmminmax", "incrmmeanstdev", "incrmgrubbs", "W", "meanstdev", "results", "minmax", "opts", "err", "buf", "sig", "mm", "ms", "tc", "gc", "df", "N", "G", "i", "getRejected", "getStatistic", "getMean", "getStDev", "getMin", "getMax", "print", "accumulator", "x", "md", "options", "decision", "digits", "str", "main"]
7
7
  }
package/lib/validate.js CHANGED
@@ -45,7 +45,7 @@ var isnan = require( '@stdlib/assert-is-nan' );
45
45
  *
46
46
  * var options = {
47
47
  * 'alpha': 0.05,
48
- * 'alernative': 'two-sided'
48
+ * 'alternative': 'two-sided'
49
49
  * };
50
50
  *
51
51
  * var err = validate( opts, options );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-incr-mgrubbs",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Moving Grubbs' test for outliers.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,26 +30,27 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/array-float64": "^0.2.1",
34
- "@stdlib/assert-has-own-property": "^0.2.1",
35
- "@stdlib/assert-is-boolean": "^0.2.1",
36
- "@stdlib/assert-is-nan": "^0.2.1",
37
- "@stdlib/assert-is-number": "^0.2.1",
38
- "@stdlib/assert-is-plain-object": "^0.2.1",
39
- "@stdlib/assert-is-positive-integer": "^0.2.1",
40
- "@stdlib/assert-is-string": "^0.2.1",
41
- "@stdlib/constants-float64-ninf": "^0.2.1",
42
- "@stdlib/constants-float64-pinf": "^0.2.1",
43
- "@stdlib/math-base-assert-is-nan": "^0.2.1",
44
- "@stdlib/math-base-assert-is-negative-zero": "^0.2.1",
45
- "@stdlib/math-base-assert-is-positive-zero": "^0.2.1",
46
- "@stdlib/math-base-special-max": "^0.2.1",
47
- "@stdlib/math-base-special-roundn": "^0.2.1",
48
- "@stdlib/math-base-special-sqrt": "^0.2.1",
33
+ "@stdlib/array-float64": "^0.2.2",
34
+ "@stdlib/assert-has-own-property": "^0.2.2",
35
+ "@stdlib/assert-is-boolean": "^0.2.2",
36
+ "@stdlib/assert-is-nan": "^0.2.2",
37
+ "@stdlib/assert-is-number": "^0.2.2",
38
+ "@stdlib/assert-is-plain-object": "^0.2.2",
39
+ "@stdlib/assert-is-positive-integer": "^0.2.2",
40
+ "@stdlib/assert-is-string": "^0.2.2",
41
+ "@stdlib/constants-float64-ninf": "^0.2.2",
42
+ "@stdlib/constants-float64-pinf": "^0.2.2",
43
+ "@stdlib/math-base-assert-is-nan": "^0.2.2",
44
+ "@stdlib/math-base-assert-is-negative-zero": "^0.2.2",
45
+ "@stdlib/math-base-assert-is-positive-zero": "^0.2.2",
46
+ "@stdlib/math-base-special-max": "^0.3.0",
47
+ "@stdlib/math-base-special-roundn": "^0.2.2",
48
+ "@stdlib/math-base-special-sqrt": "^0.2.2",
49
49
  "@stdlib/stats-base-dists-t-quantile": "^0.2.1",
50
- "@stdlib/string-format": "^0.2.1",
51
- "@stdlib/utils-define-read-only-accessor": "^0.2.1",
52
- "@stdlib/utils-define-read-only-property": "^0.2.1"
50
+ "@stdlib/string-format": "^0.2.2",
51
+ "@stdlib/utils-define-read-only-accessor": "^0.2.2",
52
+ "@stdlib/utils-define-read-only-property": "^0.2.2",
53
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
53
54
  },
54
55
  "devDependencies": {},
55
56
  "engines": {