diff --git a/lib/node_modules/@stdlib/stats/base/max-by/README.md b/lib/node_modules/@stdlib/stats/base/max-by/README.md
index 96c7229df2f2..f02bfbf9a919 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/README.md
+++ b/lib/node_modules/@stdlib/stats/base/max-by/README.md
@@ -30,7 +30,7 @@ limitations under the License.
var maxBy = require( '@stdlib/stats/base/max-by' );
```
-#### maxBy( N, x, stride, clbk\[, thisArg] )
+#### maxBy( N, x, strideX, clbk\[, thisArg] )
Calculates the maximum value of strided array `x` via a callback function.
@@ -49,7 +49,7 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array], [`typed array`][mdn-typed-array], or an array-like object (excluding strings and functions).
-- **stride**: index increment.
+- **strideX**: stride length.
- **clbk**: callback function.
- **thisArg**: execution context (_optional_).
@@ -81,19 +81,16 @@ var cnt = context.count;
// returns 8
```
-The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to access every other element
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element
```javascript
-var floor = require( '@stdlib/math/base/special/floor' );
-
function accessor( v ) {
return v * 2.0;
}
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
-var N = floor( x.length / 2 );
-var v = maxBy( N, x, 2, accessor );
+var v = maxBy( 4, x, 2, accessor );
// returns 8.0
```
@@ -101,7 +98,6 @@ 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' );
function accessor( v ) {
return v * 2.0;
@@ -112,14 +108,13 @@ var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
// Create an offset view...
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
-var N = floor( x0.length/2 );
// Access every other element...
-var v = maxBy( N, x1, 2, accessor );
+var v = maxBy( 3, x1, 2, accessor );
// returns -4.0
```
-#### maxBy.ndarray( N, x, stride, offset, clbk\[, thisArg] )
+#### maxBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
Calculates the maximum value of strided array `x` via a callback function and using alternative indexing semantics.
@@ -136,9 +131,9 @@ var v = maxBy.ndarray( x.length, x, 1, 0, accessor );
The function has the following additional parameters:
-- **offset**: starting index.
+- **offsetX**: starting index.
-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 access only the last three elements of `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 access only the last three elements of the strided array
```javascript
function accessor( v ) {
@@ -160,6 +155,7 @@ var v = maxBy.ndarray( 3, x, 1, x.length-3, accessor );
## 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]).
- A provided callback function should return a numeric value.
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**.
- When possible, prefer using [`dmax`][@stdlib/stats/strided/dmax], [`smax`][@stdlib/stats/base/smax], and/or [`max`][@stdlib/stats/base/max], as, depending on the environment, these interfaces are likely to be significantly more performant.
@@ -220,6 +216,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/strided/dmax]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dmax
diff --git a/lib/node_modules/@stdlib/stats/base/max-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/max-by/benchmark/benchmark.js
index 1fa249e06191..1eeea2ef350f 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/max-by/benchmark/benchmark.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 maxBy = require( './../lib/max_by.js' );
+// VARIABLES //
+
+var options = {
+ 'dtype': 'generic'
+};
+
+
// FUNCTIONS //
/**
@@ -49,13 +56,7 @@ function accessor( value ) {
* @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/max-by/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/max-by/benchmark/benchmark.ndarray.js
index 6d6c35b06fd6..876d2bf0f00b 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/max-by/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 maxBy = require( './../lib/ndarray.js' );
+// VARIABLES //
+
+var options = {
+ 'dtype': 'generic'
+};
+
+
// FUNCTIONS //
/**
@@ -49,13 +56,7 @@ function accessor( value ) {
* @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/max-by/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/max-by/docs/repl.txt
index 177b7b5f91ff..abc04b3cbf07 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/max-by/docs/repl.txt
@@ -1,8 +1,8 @@
-{{alias}}( N, x, stride, clbk[, thisArg] )
+{{alias}}( N, x, strideX, clbk[, thisArg] )
Calculates the maximum value of a strided array via a callback function.
- The `N` and `stride` parameters determine which elements in `x` are accessed
+ 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 typed
@@ -31,8 +31,8 @@
Input array/collection. If provided an object, the object must be array-
like (excluding strings and functions).
- stride: integer
- Index increment for `x`.
+ strideX: integer
+ Stride length for `x`.
clbk: Function
Callback function.
@@ -53,20 +53,18 @@
> {{alias}}( x.length, x, 1, accessor )
8.0
- // Using `N` and `stride` parameters:
+ // Using `N` and stride parameters:
> x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}( N, x, 2, accessor )
+ > {{alias}}( 3, x, 2, accessor )
8.0
// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.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 );
- > {{alias}}( N, x1, 2, accessor )
+ > {{alias}}( 3, x1, 2, accessor )
-4.0
-{{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] )
+{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] )
Calculates the maximum value of a strided array via a callback function and
using alternative indexing semantics.
@@ -83,10 +81,10 @@
Input array/collection. If provided an object, the object must be array-
like (excluding strings and functions).
- stride: integer
- Index increment for `x`.
+ strideX: integer
+ Stride length for `x`.
- offset: integer
+ offsetX: integer
Starting index of `x`.
clbk: Function
@@ -110,8 +108,7 @@
// Using an index offset:
> x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}.ndarray( N, x, 2, 1, accessor )
+ > {{alias}}.ndarray( 3, x, 2, 1, accessor )
-4.0
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/max-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/max-by/docs/types/index.d.ts
index 71733418f849..8ca458f9a580 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/max-by/docs/types/index.d.ts
@@ -20,7 +20,12 @@
///
-import { Collection } from '@stdlib/types/array';
+import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
+
+ /**
+ * Input array.
+ */
+ type InputArray = NumericArray | Collection | AccessorArrayLike;
/**
* Returns an accessed value.
@@ -131,8 +136,8 @@ interface Routine {
*
* @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
* @param clbk - callback
* @param thisArg - execution context
* @returns maximum value
@@ -147,7 +152,7 @@ interface Routine {
* var v = maxBy.ndarray( x.length, x, 1, 0, accessor );
* // returns 8.0
*/
- ndarray( N: number, x: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
+ ndarray( N: number, x: Collection, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): number;
}
/**
@@ -166,7 +171,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
* @param clbk - callback
* @param thisArg - execution context
* @returns maximum value
diff --git a/lib/node_modules/@stdlib/stats/base/max-by/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/max-by/docs/types/test.ts
index d03925870c1c..ddc38778b978 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/stats/base/max-by/docs/types/test.ts
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import AccessorArray = require( '@stdlib/array/base/accessor' );
import maxBy = require( './index' );
const accessor = (): number => {
@@ -31,6 +32,7 @@ const accessor = (): number => {
maxBy( x.length, x, 1, accessor ); // $ExpectType number
maxBy( x.length, x, 1, accessor, {} ); // $ExpectType number
+ maxBy( x.length, new AccessorArray( x ), 1, accessor, {} ); // $ExpectType number
}
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -103,6 +105,7 @@ const accessor = (): number => {
maxBy.ndarray( x.length, x, 1, 0, accessor ); // $ExpectType number
maxBy.ndarray( x.length, x, 1, 0, accessor, {} ); // $ExpectType number
+ maxBy.ndarray( x.length, new AccessorArray( x ), 1, 0, accessor, {} ); // $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/max-by/lib/index.js b/lib/node_modules/@stdlib/stats/base/max-by/lib/index.js
index 29304e7b467b..db99ce9f4e46 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/max-by/lib/index.js
@@ -50,11 +50,18 @@
// MODULES //
-var maxBy = 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 = maxBy;
+module.exports = main;
-// exports: { "ndarray": "maxBy.ndarray" }
+// exports: { "ndarray": "main.ndarray" }
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/stats/base/max-by/lib/main.js b/lib/node_modules/@stdlib/stats/base/max-by/lib/main.js
index fa380c09009f..31c400d767b3 100644
--- a/lib/node_modules/@stdlib/stats/base/max-by/lib/main.js
+++ b/lib/node_modules/@stdlib/stats/base/max-by/lib/main.js
@@ -20,16 +20,34 @@
// MODULES //
-var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var maxBy = require( './max_by.js' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
var ndarray = require( './ndarray.js' );
// MAIN //
-setReadOnly( maxBy, 'ndarray', ndarray );
-
-
-// EXPORTS //
+/**
+ * Calculates the maximum value of a strided array via a callback function.
+ *
+ * @param {PositiveInteger} N - number of indexed elements
+ * @param {NumericArray} x - input array
+ * @param {integer} strideX - stride length
+ * @param {Callback} clbk - callback function
+ * @param {*} [thisArg] - execution context
+ * @returns {number} maximum value
+ *
+ * @example
+ * var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
+ *
+ * function accessor( v ) {
+ * return v * 2.0;
+ * }
+ *
+ * var v = maxBy( x.length, x, 1, accessor );
+ * // returns 8.0
+ */
+function maxBy( N, x, strideX, clbk, thisArg ) {
+ return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );
+}
module.exports = maxBy;
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/README.md b/lib/node_modules/@stdlib/stats/base/stdevyc/README.md
index 2ddfad8004fa..27851256a4c0 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/README.md
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/README.md
@@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
var stdevyc = require( '@stdlib/stats/base/stdevyc' );
```
-#### stdevyc( N, correction, x, stride )
+#### stdevyc( N, correction, x, strideX )
Computes the [standard deviation][standard-deviation] of a strided array `x` using a one-pass algorithm proposed by Youngs and Cramer.
@@ -114,17 +114,14 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
- **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 [standard deviation][standard-deviation] 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 [standard deviation][standard-deviation] 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 = stdevyc( N, 1, x, 2 );
+var v = stdevyc( 4, 1, x, 2 );
// returns 2.5
```
@@ -134,18 +131,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 = stdevyc( N, 1, x1, 2 );
+var v = stdevyc( 4, 1, x1, 2 );
// returns 2.5
```
-#### stdevyc.ndarray( N, correction, x, stride, offset )
+#### stdevyc.ndarray( N, correction, x, strideX , offsetX )
Computes the [standard deviation][standard-deviation] of a strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
@@ -158,17 +152,14 @@ var v = stdevyc.ndarray( x.length, 1, x, 1, 0 );
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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
+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 [standard deviation][standard-deviation] for every other element in the strided array starting from the second element
```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 = stdevyc.ndarray( N, 1, x, 2, 1 );
+var v = stdevyc.ndarray( 4, 1, x, 2, 1 );
// returns 2.5
```
@@ -181,6 +172,7 @@ var v = stdevyc.ndarray( N, 1, 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]).
- If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both functions return `NaN`.
- Depending on the environment, the typed versions ([`dstdevyc`][@stdlib/stats/base/dstdevyc], [`sstdevyc`][@stdlib/stats/base/sstdevyc], etc.) are likely to be significantly more performant.
@@ -195,18 +187,12 @@ var v = stdevyc.ndarray( N, 1, 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 stdevyc = require( '@stdlib/stats/base/stdevyc' );
-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 = stdevyc( x.length, 1, x, 1 );
@@ -257,6 +243,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
+
[@youngs:1971a]: https://doi.org/10.1080/00401706.1971.10488826
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.js
index c04b66da0f6a..05004de1cc35 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.js
@@ -21,13 +21,19 @@
// 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 stdevyc = require( './../lib/stdevyc.js' );
+var stdevyc = require( './../lib/main.js' );
+ // VARIABLES //
+
+ var options = {
+ 'dtype': 'generic'
+ };
+
// FUNCTIONS //
/**
@@ -38,13 +44,7 @@ var stdevyc = require( './../lib/stdevyc.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/stdevyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.ndarray.js
index ec00dbc56160..05544364ee88 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/benchmark/benchmark.ndarray.js
@@ -21,12 +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 stdevyc = require( './../lib/ndarray.js' );
+// VARIABLES //
+
+var options = {
+ 'dtype': 'generic'
+};
+
// FUNCTIONS //
@@ -38,13 +44,7 @@ var stdevyc = 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/stdevyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/stdevyc/docs/repl.txt
index df1c1fc4b8ed..8730fcb9237a 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/docs/repl.txt
@@ -1,9 +1,9 @@
-{{alias}}( N, correction, x, stride )
+{{alias}}( N, correction, x, strideX )
Computes the standard deviation of a strided array using a one-pass
algorithm proposed by Youngs and Cramer.
- The `N` and `stride` parameters determine which elements in `x` are accessed
+ 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
@@ -31,8 +31,8 @@
x: Array|TypedArray
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
Returns
-------
@@ -46,22 +46,18 @@
> {{alias}}( x.length, 1, x, 1 )
~2.0817
- // 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, 1, x, stride )
+ > {{alias}}( 3, 1, x, 2 )
~2.0817
// 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, 1, x1, stride )
+ > {{alias}}( 3, 1, x1, 2 )
~2.0817
-{{alias}}.ndarray( N, correction, x, stride, offset )
+{{alias}}.ndarray( N, correction, x, strideX, offsetX )
Computes the standard deviation of a strided array using a one-pass
algorithm proposed by Youngs and Cramer and alternative indexing semantics.
@@ -89,10 +85,10 @@
x: Array|TypedArray
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
- offset: integer
+ offsetX: integer
Starting index.
Returns
@@ -109,8 +105,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, 1, x, 2, 1 )
+ > {{alias}}.ndarray( 3, 1, x, 2, 1 )
~2.0817
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/index.d.ts
index 98e70a8ef7e7..f349fef42ec0 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/index.d.ts
@@ -20,8 +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 `stdevyc`.
*/
@@ -32,7 +36,7 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
- * @param stride - stride length
+ * @param strideX - stride length
* @returns standard deviation
*
* @example
@@ -41,7 +45,7 @@ interface Routine {
* var v = stdevyc( x.length, 1, x, 1 );
* // returns ~2.0817
*/
- ( N: number, correction: number, x: NumericArray, stride: number ): number;
+ ( N: number, correction: number, x: InputArray, strideX: number ): number;
/**
* Computes the standard deviation of a strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
@@ -49,8 +53,8 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
- * @param stride - stride length
- * @param offset - starting index
+ * @param strideX - stride length
+ * @param offsetX - starting index
* @returns standard deviation
*
* @example
@@ -59,7 +63,7 @@ interface Routine {
* var v = stdevyc.ndarray( x.length, 1, x, 1, 0 );
* // returns ~2.0817
*/
- ndarray( N: number, correction: number, x: NumericArray, stride: number, offset: number ): number;
+ ndarray( N: number, correction: number, x: InputArray, strideX: number, offsetX: number ): number;
}
/**
@@ -68,7 +72,7 @@ interface Routine {
* @param N - number of indexed elements
* @param correction - degrees of freedom adjustment
* @param x - input array
-* @param stride - stride length
+* @param strideX - stride length
* @returns standard deviation
*
* @example
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/test.ts
index 8e93e0a98b06..b1720123c60c 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/docs/types/test.ts
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import AccessorArray = require( '@stdlib/array/base/accessor' );
import stdevyc = require( './index' );
@@ -26,6 +27,7 @@ import stdevyc = require( './index' );
const x = new Float64Array( 10 );
stdevyc( x.length, 1, x, 1 ); // $ExpectType number
+ stdevyc( x.length, 1, new AccessorArray( x ), 1 ); // $ExpectType number
}
// The compiler throws an error if the function is provided a first argument which is not a number...
@@ -101,6 +103,7 @@ import stdevyc = require( './index' );
const x = new Float64Array( 10 );
stdevyc.ndarray( x.length, 1, x, 1, 0 ); // $ExpectType number
+ stdevyc.ndarray( x.length, 1, 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/stdevyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/stdevyc/examples/index.js
index 62393d3f8151..b3c6ceb20938 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/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 stdevyc = 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 = stdevyc( x.length, 1, x, 1 );
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/accessors.js b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/accessors.js
new file mode 100644
index 000000000000..bb69f278758a
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/accessors.js
@@ -0,0 +1,96 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var sqrt = require( '@stdlib/math/base/special/sqrt' );
+
+
+// MAIN //
+
+/**
+* Computes the standard deviation of a strided array using Youngs and Cramer's method.
+*
+* @private
+* @param {PositiveInteger} N - number of indexed elements
+* @param {NonNegativeInteger} correction - degrees of freedom adjustment (0 for population, 1 for sample)
+* @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} standard deviation
+*
+* @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 = stdevyc( 4, 1, arraylike2object( x ), 2, 1 );
+* // returns
+*/
+function stdevyc( N, correction, x, strideX, offsetX ) {
+ var delta;
+ var count;
+ var xbuf;
+ var mean;
+ var get;
+ var M2;
+ 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 <= correction ) { // Prevent division by zero
+ return NaN;
+ }
+
+ // Initialize variables:
+ mean = 0.0;
+ M2 = 0.0;
+ count = 0;
+ ix = offsetX;
+
+ for ( i = 0; i < N; i++ ) {
+ v = get( xbuf, ix );
+ if ( isnan( v ) ) {
+ return NaN;
+ }
+ count += 1;
+ delta = v - mean;
+ mean += delta / count;
+ M2 += delta * ( v - mean );
+ ix += strideX;
+ }
+
+ return sqrt( M2 / ( count - correction ) );
+}
+
+
+// EXPORTS //
+
+module.exports = stdevyc;
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/index.js
index 4466e430d335..1d655aef6c50 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/index.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* 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.
@@ -32,21 +32,25 @@
* // returns ~2.0817
*
* @example
-* var floor = require( '@stdlib/math/base/special/floor' );
* var stdevyc = require( '@stdlib/stats/base/stdevyc' );
*
* 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 = stdevyc.ndarray( N, 1, x, 2, 1 );
+* var v = stdevyc.ndarray( 4, 1, x, 2, 1 );
* // returns 2.5
*/
// MODULES //
-var main = 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 = main;
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/main.js b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/main.js
index 3df6b62d7501..ca28f6ba486e 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/main.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/main.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* 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.
@@ -20,14 +20,37 @@
// MODULES //
-var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
-var stdevyc = require( './stdevyc.js' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
var ndarray = require( './ndarray.js' );
// MAIN //
-setReadOnly( stdevyc, 'ndarray', ndarray );
+/**
+ * Computes the standard deviation of a strided array using a one-pass algorithm proposed by Youngs and Cramer.
+*
+* ## References
+*
+* - Youngs, Edward A., and Elliot M. Cramer. 1971. "Some Results Relevant to Choice of Sum and Sum-of-Product Algorithms." _Technometrics_ 13 (3): 657–65. doi:[10.1080/00401706.1971.10488826](https://doi.org/10.1080/00401706.1971.10488826).
+
+ * @param {PositiveInteger} N - number of indexed elements
+ * @param {number} correction - degrees of freedom adjustment
+ * @param {NumericArray} x - input array
+ * @param {integer} strideX - stride length
+ * @returns {number} standard deviation
+ *
+ * @example
+ * var x = [ 1.0, -2.0, 2.0 ];
+ *
+ * var v = stdevyc( x.length, 1, x, 1 );
+ * // returns ~2.0817
+ */
+function stdevyc( N, correction, x, strideX ) {
+ return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) );
+}
+
+// EXPORTS //
+module.exports = stdevyc;
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/ndarray.js
index f69a3652a931..a21a5f1e7310 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/ndarray.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* 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.
@@ -20,8 +20,11 @@
// MODULES //
-var varianceyc = require( '@stdlib/stats/base/varianceyc' ).ndarray;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+var accessors = require( './accessors.js' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
+var varianceyc = require( '@stdlib/stats/base/varianceyc' ).ndarray;
// MAIN //
@@ -36,21 +39,27 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @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} standard deviation
*
* @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 x = [ 1.0, -2.0, 2.0 ];
*
-* var v = stdevyc( N, 1, x, 2, 1 );
-* // returns 2.5
+* var v = stdevyc( x.length, 1, x, 1, 0 );
+* // returns ~2.0817
*/
-function stdevyc( N, correction, x, stride, offset ) {
- return sqrt( varianceyc( N, correction, x, stride, offset ) );
+function stdevyc( N, correction, x, strideX, offsetX ) {
+ var o;
+
+ if ( N <= 0 ) {
+ return NaN;
+ }
+ o = arraylike2object( x );
+ if ( o.accessorProtocol ) {
+ return accessors( N, correction, o, strideX, offsetX );
+ }
+ return sqrt( varianceyc( N, correction, x, strideX, offsetX ) );
}
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/stdevyc.js b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/stdevyc.js
index 3030bafe696a..50ff909fd37e 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/lib/stdevyc.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/lib/stdevyc.js
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* 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.
@@ -20,9 +20,11 @@
// MODULES //
-var varianceyc = require( '@stdlib/stats/base/varianceyc' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+var accessors = require( './accessors.js' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
-
+var varianceyc = require( '@stdlib/stats/base/varianceyc' ).ndarray;
// MAIN //
@@ -36,17 +38,27 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {NumericArray} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
* @returns {number} standard deviation
*
* @example
* var x = [ 1.0, -2.0, 2.0 ];
*
-* var v = stdevyc( x.length, 1, x, 1 );
+* var v = stdevyc( x.length, 1, x, 1, 0 );
* // returns ~2.0817
*/
-function stdevyc( N, correction, x, stride ) {
- return sqrt( varianceyc( N, correction, x, stride ) );
+function stdevyc( N, correction, x, strideX ) {
+ var o;
+
+ if ( N <= 0 ) {
+ return NaN;
+ }
+ o = arraylike2object( x );
+ if ( o.accessorProtocol ) {
+ return accessors( N, correction, o, strideX, 0 );
+ }
+ return sqrt( varianceyc( N, correction, x, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.ndarray.js
index 7d8a571e5c7f..db276805db6d 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.ndarray.js
@@ -21,9 +21,9 @@
// MODULES //
var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
var stdevyc = require( './../lib/ndarray.js' );
@@ -59,6 +59,25 @@ tape( 'the function calculates the population standard deviation of a strided ar
t.end();
});
+tape( 'the function calculates the population standard deviation of a strided array (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = toAccessorArray( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] );
+ v = stdevyc( x.length, 0, x, 1, 0 );
+ t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' );
+
+ x = [ -4.0, -4.0 ];
+ v = stdevyc( x.length, 0, x, 1, 0 );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ x = [ NaN, 4.0 ];
+ v = stdevyc( x.length, 0, x, 1, 0 );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function calculates the sample standard deviation of a strided array', function test( t ) {
var x;
var v;
@@ -93,6 +112,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
t.end();
});
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = stdevyc( 0, 1, toAccessorArray( x ), 1, 0 );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ v = stdevyc( -1, 1, toAccessorArray( x ), 1, 0 );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0`', function test( t ) {
var x;
var v;
@@ -105,6 +139,18 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
t.end();
});
+tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = stdevyc( 1, 0, toAccessorArray( x ), 1, 0 );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN`', function test( t ) {
var x;
var v;
@@ -120,8 +166,22 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
t.end();
});
+tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns `NaN` (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = stdevyc( x.length, x.length, toAccessorArray( x ), 1, 0 );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ v = stdevyc( x.length, x.length+1, toAccessorArray( x ), 1, 0 );
+ t.strictEqual( isnan( v ), true, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -136,15 +196,34 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
2.0
];
- N = floor( x.length / 2 );
- v = stdevyc( N, 1, x, 2, 0 );
+ v = stdevyc( 4, 1, x, 2, 0 );
+
+ t.strictEqual( v, 2.5, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function supports a `stride` parameter (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [
+ 1.0, // 0
+ 2.0,
+ 2.0, // 1
+ -7.0,
+ -2.0, // 2
+ 3.0,
+ 4.0, // 3
+ 2.0
+ ];
+
+ v = stdevyc( 4, 1, toAccessorArray( x ), 2, 0 );
t.strictEqual( v, 2.5, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -159,8 +238,28 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
];
- N = floor( x.length / 2 );
- v = stdevyc( N, 1, x, -2, 6 );
+ v = stdevyc( 4, 1, x, -2, 6 );
+
+ t.strictEqual( v, 2.5, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function supports a negative `stride` parameter (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [
+ 1.0, // 3
+ 2.0,
+ 2.0, // 2
+ -7.0,
+ -2.0, // 1
+ 3.0,
+ 4.0, // 0
+ 2.0
+ ];
+
+ v = stdevyc( 4, 1, toAccessorArray( x ), -2, 6 );
t.strictEqual( v, 2.5, 'returns expected value' );
t.end();
@@ -178,8 +277,19 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
t.end();
});
+tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
+
+ v = stdevyc( x.length, 1, toAccessorArray( x ), 0, 0 );
+ t.strictEqual( v, 0.0, 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function supports an `offset` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -193,9 +303,29 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
3.0,
4.0 // 3
];
- N = floor( x.length / 2 );
- v = stdevyc( N, 1, x, 2, 1 );
+ v = stdevyc( 4, 1, x, 2, 1 );
+ t.strictEqual( v, 2.5, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports an `offset` parameter (accessor)', function test( t ) {
+ var x;
+ var v;
+
+ x = [
+ 2.0,
+ 1.0, // 0
+ 2.0,
+ -2.0, // 1
+ -2.0,
+ 2.0, // 2
+ 3.0,
+ 4.0 // 3
+ ];
+
+ v = stdevyc( 4, 1, toAccessorArray( x ), 2, 1 );
t.strictEqual( v, 2.5, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.stdevyc.js b/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.stdevyc.js
index 7eb5dc11d7b1..a6bf1ee7e913 100644
--- a/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.stdevyc.js
+++ b/lib/node_modules/@stdlib/stats/base/stdevyc/test/test.stdevyc.js
@@ -21,7 +21,6 @@
// MODULES //
var tape = require( 'tape' );
-var floor = require( '@stdlib/math/base/special/floor' );
var sqrt = require( '@stdlib/math/base/special/sqrt' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Float64Array = require( '@stdlib/array/float64' );
@@ -122,7 +121,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -137,15 +135,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
2.0
];
- N = floor( x.length / 2 );
- v = stdevyc( N, 1, x, 2 );
+ v = stdevyc( 4, 1, x, 2 );
t.strictEqual( v, 2.5, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -160,8 +156,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
2.0
];
- N = floor( x.length / 2 );
- v = stdevyc( N, 1, x, -2 );
+ v = stdevyc( 4, 1, x, -2 );
t.strictEqual( v, 2.5, 'returns expected value' );
t.end();
@@ -182,7 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`',
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -198,9 +192,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 = stdevyc( N, 1, x1, 2 );
+ v = stdevyc( 4, 1, x1, 2 );
t.strictEqual( v, 2.5, 'returns expected value' );
t.end();