diff --git a/lib/node_modules/@stdlib/stats/base/mean/README.md b/lib/node_modules/@stdlib/stats/base/mean/README.md index 2b887ff25993..f1d70e061432 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/README.md +++ b/lib/node_modules/@stdlib/stats/base/mean/README.md @@ -51,15 +51,14 @@ The [arithmetic mean][arithmetic-mean] is defined as var mean = require( '@stdlib/stats/base/mean' ); ``` -#### mean( N, x, stride ) +#### mean( N, x, strideX ) Computes the [arithmetic mean][arithmetic-mean] of a strided array `x`. ```javascript var x = [ 1.0, -2.0, 2.0 ]; -var N = x.length; -var v = mean( N, x, 1 ); +var v = mean( x.length, x, 1 ); // returns ~0.3333 ``` @@ -67,17 +66,14 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array]. -- **stride**: index increment for `x`. +- **strideX**: stride length for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`, +The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`, ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); - var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ]; -var N = floor( x.length / 2 ); -var v = mean( N, x, 2 ); +var v = mean( 4, x, 2 ); // returns 1.25 ``` @@ -87,18 +83,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = mean( N, x1, 2 ); +var v = mean( 4, x1, 2 ); // returns 1.25 ``` -#### mean.ndarray( N, x, stride, offset ) +#### mean.ndarray( N, x, strideX, offsetX ) Computes the [arithmetic mean][arithmetic-mean] of a strided array using alternative indexing semantics. @@ -106,23 +99,20 @@ Computes the [arithmetic mean][arithmetic-mean] of a strided array using alterna var x = [ 1.0, -2.0, 2.0 ]; var N = x.length; -var v = mean.ndarray( N, x, 1, 0 ); +var v = mean.ndarray( x.length, x, 1, 0 ); // returns ~0.33333 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: starting index for `x`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value ```javascript -var floor = require( '@stdlib/math/base/special/floor' ); - var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; -var N = floor( x.length / 2 ); -var v = mean.ndarray( N, x, 2, 1 ); +var v = mean.ndarray( 4, x, 2, 1 ); // returns 1.25 ``` @@ -135,6 +125,7 @@ var v = mean.ndarray( N, x, 2, 1 ); ## Notes - If `N <= 0`, both functions return `NaN`. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - Depending on the environment, the typed versions ([`dmean`][@stdlib/stats/base/dmean], [`smean`][@stdlib/stats/base/smean], etc.) are likely to be significantly more performant. @@ -148,18 +139,12 @@ var v = mean.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var mean = require( '@stdlib/stats/base/mean' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); var v = mean( x.length, x, 1 ); @@ -196,6 +181,8 @@ console.log( v ); [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray +[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor + [@stdlib/stats/base/dmean]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dmean diff --git a/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.js index 55e99bd7552e..a2a3a9543b13 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.js @@ -21,11 +21,18 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; -var mean = require( './../lib/mean.js' ); +var mean = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; // FUNCTIONS // @@ -38,13 +45,7 @@ var mean = require( './../lib/mean.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - } + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.ndarray.js index 943b227947b0..e138067a02b6 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/mean/benchmark/benchmark.ndarray.js @@ -21,13 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var pkg = require( './../package.json' ).name; var mean = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + // FUNCTIONS // /** @@ -38,13 +45,7 @@ var mean = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( ( randu()*20.0 ) - 10.0 ); - } + var x = uniform( len, -10, 10, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/mean/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/mean/docs/repl.txt index 13d2980a8375..dd22e07ac33d 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/mean/docs/repl.txt @@ -1,12 +1,12 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the arithmetic mean of a strided array. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and `stride` parameters determine which elements in the strided + array are accessed at runtime. - Indexing is relative to the first index. To introduce an offset, use a typed - array view. + Indexing is relative to the first index. To introduce an offset, use a + typed array view. If `N <= 0`, the function returns `NaN`. @@ -18,8 +18,8 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -33,22 +33,19 @@ > {{alias}}( x.length, x, 1 ) ~0.3333 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 3, x, 2 ) ~0.3333 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 3, x1, 2 ) ~-0.3333 -{{alias}}.ndarray( N, x, stride, offset ) + +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the arithmetic mean of a strided array using alternative indexing semantics. @@ -64,10 +61,10 @@ x: Array|TypedArray Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -84,8 +81,7 @@ // Using offset parameter: > var x = [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ]; - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 3, x, 2, 1 ) ~-0.3333 See Also diff --git a/lib/node_modules/@stdlib/stats/base/mean/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/mean/docs/types/index.d.ts index 1446424f0fec..3cc764c727bb 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/mean/docs/types/index.d.ts @@ -20,7 +20,12 @@ /// -import { NumericArray } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; /** * Interface describing `mean`. @@ -31,7 +36,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length + * @param strideX - stride length * @returns arithmetic mean * * @example @@ -40,15 +45,15 @@ interface Routine { * var v = mean( x.length, x, 1 ); * // returns ~0.3333 */ - ( N: number, x: NumericArray, stride: number ): number; + ( N: number, x: InputArray, strideX: number ): number; /** * Computes the arithmetic mean of a strided array using alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @returns arithmetic mean * * @example @@ -57,7 +62,7 @@ interface Routine { * var v = mean.ndarray( x.length, x, 1, 0 ); * // returns ~0.3333 */ - ndarray( N: number, x: NumericArray, stride: number, offset: number ): number; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number ): number; } /** @@ -65,7 +70,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns arithmetic mean * * @example diff --git a/lib/node_modules/@stdlib/stats/base/mean/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/mean/docs/types/test.ts index 1bc548bf632e..52d167f7b248 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/mean/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import AccessorArray = require( '@stdlib/array/base/accessor' ); import mean = require( './index' ); @@ -26,6 +27,7 @@ import mean = require( './index' ); const x = new Float64Array( 10 ); mean( x.length, x, 1 ); // $ExpectType number + mean( x.length, new AccessorArray( x ), 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -85,6 +87,7 @@ import mean = require( './index' ); const x = new Float64Array( 10 ); mean.ndarray( x.length, x, 1, 0 ); // $ExpectType number + mean.ndarray( x.length, new AccessorArray( x ), 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/stats/base/mean/examples/index.js b/lib/node_modules/@stdlib/stats/base/mean/examples/index.js index be7e0eec2bee..7895bab74f19 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/mean/examples/index.js @@ -18,18 +18,12 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var mean = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); var v = mean( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/mean/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/mean/lib/accessors.js new file mode 100644 index 000000000000..76693a71ace1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/mean/lib/accessors.js @@ -0,0 +1,85 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Computes the arithmetic mean of a strided array. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @returns {number} arithmetic mean +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +* +* var v = mean( 4, arraylike2object( x ), 2, 1 ); +* // returns 1.25 +*/ +function mean( N, x, strideX, offsetX ) { + var xbuf; + var get; + var sum; + var ix; + var v; + var i; + + // Cache reference to array data: + xbuf = x.data; + + // Cache a reference to the element accessor: + get = x.accessors[ 0 ]; + + if ( N <= 0 ) { + return NaN; + } + if ( N === 1 || strideX === 0 ) { + return get( xbuf, offsetX ); + } + ix = offsetX; + sum = 0; + for ( i = 0; i < N; i++ ) { + v = get( xbuf, ix ); + if ( isnan( v ) ) { + return v; + } + sum += v; + ix += strideX; + } + return sum / N; +} + + +// EXPORTS // + +module.exports = mean; diff --git a/lib/node_modules/@stdlib/stats/base/mean/lib/index.js b/lib/node_modules/@stdlib/stats/base/mean/lib/index.js index a7238a87be13..a81bea054b9b 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/mean/lib/index.js @@ -27,29 +27,33 @@ * var mean = require( '@stdlib/stats/base/mean' ); * * var x = [ 1.0, -2.0, 2.0 ]; -* var N = x.length; * -* var v = mean( N, x, 1 ); +* var v = mean( x.length, x, 1 ); * // returns ~0.3333 * * @example -* var floor = require( '@stdlib/math/base/special/floor' ); * var mean = require( '@stdlib/stats/base/mean' ); * * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; -* var N = floor( x.length / 2 ); * -* var v = mean.ndarray( N, x, 2, 1 ); +* var v = mean.ndarray( 4, x, 2, 1 ); * // returns 1.25 */ // MODULES // -var mean = require( './main.js' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); // EXPORTS // -module.exports = mean; +module.exports = main; -// exports: { "ndarray": "mean.ndarray" } +// exports: { "ndarray": "main.ndarray" } diff --git a/lib/node_modules/@stdlib/stats/base/mean/lib/main.js b/lib/node_modules/@stdlib/stats/base/mean/lib/main.js index 8df8858b5475..225297cc213d 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/mean/lib/main.js @@ -20,14 +20,30 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var mean = require( './mean.js' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); var ndarray = require( './ndarray.js' ); // MAIN // -setReadOnly( mean, 'ndarray', ndarray ); +/** +* Computes the mean value of a strided array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {NumericArray} x - input array +* @param {integer} strideX - stride length +* @returns {number} mean value +* +* @example +* var x = [ 1.0, -2.0, 2.0 ]; +* var N = x.length; +* +* var v = mean( N, x, 1 ); +* // returns 0.3333333333333333 +*/ +function mean( N, x, strideX ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ) ); +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/stats/base/mean/lib/mean.js b/lib/node_modules/@stdlib/stats/base/mean/lib/mean.js deleted file mode 100644 index 1e60e9b4cb09..000000000000 --- a/lib/node_modules/@stdlib/stats/base/mean/lib/mean.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var meanpn = require( '@stdlib/stats/base/meanpn' ); - - -// MAIN // - -/** -* Computes the arithmetic mean of a strided array. -* -* @param {PositiveInteger} N - number of indexed elements -* @param {NumericArray} x - input array -* @param {integer} stride - stride length -* @returns {number} arithmetic mean -* -* @example -* var x = [ 1.0, -2.0, 2.0 ]; -* var N = x.length; -* -* var v = mean( N, x, 1 ); -* // returns ~0.3333 -*/ -function mean( N, x, stride ) { - return meanpn( N, x, stride ); -} - - -// EXPORTS // - -module.exports = mean; diff --git a/lib/node_modules/@stdlib/stats/base/mean/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/mean/lib/ndarray.js index a79f926d9625..a219f16ef2ea 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/mean/lib/ndarray.js @@ -20,7 +20,9 @@ // MODULES // -var meanpn = require( '@stdlib/stats/base/meanpn' ).ndarray; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); // MAIN // @@ -30,21 +32,44 @@ var meanpn = require( '@stdlib/stats/base/meanpn' ).ndarray; * * @param {PositiveInteger} N - number of indexed elements * @param {NumericArray} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} arithmetic mean * * @example -* var floor = require( '@stdlib/math/base/special/floor' ); -* * var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ]; -* var N = floor( x.length / 2 ); * -* var v = mean( N, x, 2, 1 ); +* var v = mean( 4, x, 2, 1 ); * // returns 1.25 */ -function mean( N, x, stride, offset ) { - return meanpn( N, x, stride, offset ); +function mean( N, x, strideX, offsetX ) { + var sum; + var ix; + var o; + var v; + var i; + + if ( N <= 0 ) { + return NaN; + } + o = arraylike2object( x ); + if ( o.accessorProtocol ) { + return accessors( N, o, strideX, offsetX ); + } + if ( N === 1 || strideX === 0 ) { + return x[ offsetX ]; + } + ix = offsetX; + sum = 0; + for ( i = 0; i < N; i++ ) { + v = x[ ix ]; + if ( isnan( v ) ) { + return v; + } + sum += v; + ix += strideX; + } + return sum / N; } diff --git a/lib/node_modules/@stdlib/stats/base/mean/test/test.mean.js b/lib/node_modules/@stdlib/stats/base/mean/test/test.main.js similarity index 92% rename from lib/node_modules/@stdlib/stats/base/mean/test/test.mean.js rename to lib/node_modules/@stdlib/stats/base/mean/test/test.main.js index 30d00de4efe2..5c86ea94abe5 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/test/test.mean.js +++ b/lib/node_modules/@stdlib/stats/base/mean/test/test.main.js @@ -21,10 +21,9 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); -var mean = require( './../lib/mean.js' ); +var mean = require( './../lib/main.js' ); // TESTS // @@ -85,7 +84,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -100,15 +98,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - N = floor( x.length / 2 ); - v = mean( N, x, 2 ); + v = mean( 4, x, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -123,8 +119,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = mean( N, x, -2 ); + v = mean( 4, x, -2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -145,7 +140,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -161,9 +155,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = mean( N, x1, 2 ); + v = mean( 4, x1, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/mean/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/mean/test/test.ndarray.js index b191bbc1d09f..b989447538a1 100644 --- a/lib/node_modules/@stdlib/stats/base/mean/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/mean/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var mean = require( './../lib/ndarray.js' ); @@ -84,7 +83,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -99,15 +97,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]; - N = floor( x.length / 2 ); - v = mean( N, x, 2, 0 ); + v = mean( 4, x, 2, 0 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -122,8 +118,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]; - N = floor( x.length / 2 ); - v = mean( N, x, -2, 6 ); + v = mean( 4, x, -2, 6 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -142,7 +137,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -156,9 +150,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]; - N = floor( x.length / 2 ); - v = mean( N, x, 2, 1 ); + v = mean( 4, x, 2, 1 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end();