diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/README.md b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/README.md
index a096d2bcc40d..f8e457f4861d 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/README.md
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/README.md
@@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' );
```
-#### dnanvariancepn( N, correction, x, stride )
+#### dnanvariancepn( N, correction, x, strideX )
-Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using a two-pass algorithm.
+Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -116,18 +116,16 @@ 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 [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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 [`Float64Array`][@stdlib/array/float64].
-- **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 [variance][variance] 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 [variance][variance] of every other element in `x`,
```javascript
var Float64Array = require( '@stdlib/array/float64' );
-var floor = require( '@stdlib/math/base/special/floor' );
-var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
-var N = floor( x.length / 2 );
+var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ] ); // eslint-disable-line max-len
-var v = dnanvariancepn( N, 1, x, 2 );
+var v = dnanvariancepn( 5, 1, x, 2 );
// returns 6.25
```
@@ -137,18 +135,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, NaN ] );
+var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); // eslint-disable-line max-len
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
-var N = floor( x0.length / 2 );
-
-var v = dnanvariancepn( N, 1, x1, 2 );
+var v = dnanvariancepn( 5, 1, x1, 2 );
// returns 6.25
```
-#### dnanvariancepn.ndarray( N, correction, x, stride, offset )
+#### dnanvariancepn.ndarray( N, correction, x, strideX, offsetX )
Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
@@ -163,18 +158,16 @@ var v = dnanvariancepn.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 [variance][variance] 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 [variance][variance] for every other element in `x` starting from the second element
```javascript
var Float64Array = require( '@stdlib/array/float64' );
-var floor = require( '@stdlib/math/base/special/floor' );
-var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
-var N = floor( x.length / 2 );
+var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] ); // eslint-disable-line max-len
-var v = dnanvariancepn.ndarray( N, 1, x, 2, 1 );
+var v = dnanvariancepn.ndarray( 5, 1, x, 2, 1 );
// returns 6.25
```
@@ -200,18 +193,19 @@ var v = dnanvariancepn.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 uniform = require( '@stdlib/random/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' );
-var x;
-var i;
-
-x = new Float64Array( 10 );
-for ( i = 0; i < x.length; i++ ) {
- x[ i ] = round( (randu()*100.0) - 50.0 );
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -50.0, 50.0 );
}
+
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var v = dnanvariancepn( x.length, 1, x, 1 );
@@ -222,6 +216,125 @@ console.log( v );
+
+
+* * *
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/stats/base/dnanvariancepn.h"
+```
+
+#### stdlib_strided_dnanvariancepn( N, correction, \*X, strideX )
+
+Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
+
+```c
+const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
+
+double v = stdlib_strided_dnanvariancepn( 4, 1.0, x, 1 );
+// returns ~4.3333
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **correction**: `[in] double` 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 [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+
+```c
+double stdlib_strided_dnanvariancepn( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX );
+```
+
+#### stdlib_strided_dnanvariancepn_ndarray( N, correction, \*X, strideX, offsetX )
+
+Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
+
+```c
+const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
+
+double v = stdlib_strided_dnanvariancepn_ndarray( 4, 1.0, x, 1, 0 );
+// returns ~4.3333
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **correction**: `[in] double` 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 [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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**: `[in] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+
+```c
+double stdlib_strided_dnanvariancepn_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/stats/base/dnanvariancepn.h"
+#include
+
+int main( void ) {
+ // Create a strided array:
+ const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
+
+ // Specify the number of elements:
+ const int N = 6;
+
+ // Specify the stride length:
+ const int strideX = 2;
+
+ // Compute the variance:
+ double v = stdlib_strided_dnanvariancepn( N, 1.0, x, strideX );
+
+ // Print the result:
+ printf( "sample variance: %lf\n", v );
+}
+```
+
+
+
+
+
+
+
+
+
* * *
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.js
index 938fb06d261c..7693bcc04538 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.js
@@ -21,16 +21,30 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dnanvariancepn = require( './../lib/dnanvariancepn.js' );
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -39,17 +53,7 @@ var dnanvariancepn = require( './../lib/dnanvariancepn.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.native.js
index 8f55e745acf0..b40859f8428d 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.native.js
@@ -22,10 +22,11 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
@@ -40,6 +41,19 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -48,17 +62,7 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.js
index f643f79be93c..ae3f65a66ad1 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.js
@@ -21,16 +21,30 @@
// MODULES //
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var dnanvariancepn = require( './../lib/ndarray.js' );
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -39,17 +53,7 @@ var dnanvariancepn = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.native.js
index 22820da65b55..400968b5ae70 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/benchmark.ndarray.native.js
@@ -22,10 +22,11 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
-var randu = require( '@stdlib/random/base/randu' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
-var Float64Array = require( '@stdlib/array/float64' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
@@ -40,6 +41,19 @@ var opts = {
// FUNCTIONS //
+/**
+* Returns a random value or `NaN`.
+*
+* @private
+* @returns {number} random number or `NaN`
+*/
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
+ }
+ return uniform( -10.0, 10.0 );
+}
+
/**
* Creates a benchmark function.
*
@@ -48,17 +62,7 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x;
- var i;
-
- x = new Float64Array( len );
- for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = ( randu()*20.0 ) - 10.0;
- }
- }
+ var x = filledarrayBy( len, 'float64', rand );
return benchmark;
function benchmark( b ) {
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/c/benchmark.length.c
index 2b1e4f8fc994..13c9d9e7fc35 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/c/benchmark.length.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/benchmark/c/benchmark.length.c
@@ -94,7 +94,7 @@ static double rand_double( void ) {
* @param len array length
* @return elapsed time in seconds
*/
-static double benchmark( int iterations, int len ) {
+static double benchmark1( int iterations, int len ) {
double elapsed;
double x[ len ];
double v;
@@ -102,11 +102,16 @@ static double benchmark( int iterations, int len ) {
int i;
for ( i = 0; i < len; i++ ) {
- x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ if ( rand_double() < 0.2 ) {
+ x[ i ] = 0.0 / 0.0; // NaN
+ } else {
+ x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ }
}
v = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
v = stdlib_strided_dnanvariancepn( len, 1.0, x, 1 );
if ( v != v ) {
printf( "should not return NaN\n" );
@@ -120,6 +125,44 @@ static double benchmark( int iterations, int len ) {
return elapsed;
}
+/**
+* Runs a benchmark.
+*
+* @param iterations number of iterations
+* @param len array length
+* @return elapsed time in seconds
+*/
+static double benchmark2( int iterations, int len ) {
+ double elapsed;
+ double x[ len ];
+ double v;
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ if ( rand_double() < 0.2 ) {
+ x[ i ] = 0.0 / 0.0; // NaN
+ } else {
+ x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
+ }
+ }
+ v = 0.0;
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ // cppcheck-suppress uninitvar
+ v = stdlib_strided_dnanvariancepn_ndarray( len, 1.0, x, 1, 0 );
+ if ( v != v ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( v != v ) {
+ printf( "should not return NaN\n" );
+ }
+ return elapsed;
+}
+
/**
* Main execution sequence.
*/
@@ -142,7 +185,18 @@ int main( void ) {
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:len=%d\n", NAME, len );
- elapsed = benchmark( iter, len );
+ elapsed = benchmark1( iter, len );
+ print_results( iter, elapsed );
+ printf( "ok %d benchmark finished\n", count );
+ }
+ }
+ for ( i = MIN; i <= MAX; i++ ) {
+ len = pow( 10, i );
+ iter = ITERATIONS / pow( 10, i-1 );
+ for ( j = 0; j < REPEATS; j++ ) {
+ count += 1;
+ printf( "# c::%s:ndarray:len=%d\n", NAME, len );
+ elapsed = benchmark2( iter, len );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/repl.txt
index ec5c6b14c7f3..5e018c05de8c 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/repl.txt
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/repl.txt
@@ -1,10 +1,10 @@
-{{alias}}( N, correction, x, stride )
+{{alias}}( N, correction, x, strideX )
Computes the variance of a double-precision floating-point strided array
ignoring `NaN` values and using a two-pass algorithm.
- 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.
@@ -34,8 +34,8 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
Returns
-------
@@ -49,22 +49,19 @@
> {{alias}}( x.length, 1, x, 1 )
~4.3333
- // Using `N` and `stride` parameters:
- > x = new {{alias:@stdlib/array/float64}}( [ -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 )
+ // Using `N` and stride parameters:
+ > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] );
+ > {{alias}}( 4, 1, x, 2 )
~4.3333
// Using view offsets:
- > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
+ > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
> 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}}( 4, 1, x1, 2 )
~4.3333
-{{alias}}.ndarray( N, correction, x, stride, offset )
+
+{{alias}}.ndarray( N, correction, x, strideX, offsetX )
Computes the variance of a double-precision floating-point strided array
ignoring `NaN` values and using a two-pass algorithm and alternative
indexing semantics.
@@ -94,10 +91,10 @@
x: Float64Array
Input array.
- stride: integer
- Index increment.
+ strideX: integer
+ Stride length.
- offset: integer
+ offsetX: integer
Starting index.
Returns
@@ -113,9 +110,8 @@
~4.3333
// Using offset parameter:
- > var x = new {{alias:@stdlib/array/float64}}( [ 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 )
+ > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
+ > {{alias}}.ndarray( 4, 1, x, 2, 1 )
~4.3333
See Also
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/types/index.d.ts
index 7a095f9ad539..abfb3a863547 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/docs/types/index.d.ts
@@ -28,7 +28,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 variance
*
* @example
@@ -39,7 +39,7 @@ interface Routine {
* var v = dnanvariancepn( x.length, 1, x, 1 );
* // returns ~4.3333
*/
- ( N: number, correction: number, x: Float64Array, stride: number ): number;
+ ( N: number, correction: number, x: Float64Array, strideX: number ): number;
/**
* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
@@ -47,8 +47,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 variance
*
* @example
@@ -59,7 +59,7 @@ interface Routine {
* var v = dnanvariancepn.ndarray( x.length, 1, x, 1, 0 );
* // returns ~4.3333
*/
- ndarray( N: number, correction: number, x: Float64Array, stride: number, offset: number ): number;
+ ndarray( N: number, correction: number, x: Float64Array, strideX: number, offsetX: number ): number;
}
/**
@@ -68,7 +68,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 variance
*
* @example
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/c/example.c
index d557e4a16994..bdcfe68be923 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/c/example.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/c/example.c
@@ -17,21 +17,20 @@
*/
#include "stdlib/stats/base/dnanvariancepn.h"
-#include
#include
int main( void ) {
// Create a strided array:
- double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
+ const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
// Specify the number of elements:
- int64_t N = 6;
+ const int N = 6;
// Specify the stride length:
- int64_t stride = 2;
+ const int strideX = 2;
// Compute the variance:
- double v = stdlib_strided_dnanvariancepn( N, 1, x, stride );
+ double v = stdlib_strided_dnanvariancepn( N, 1.0, x, strideX );
// Print the result:
printf( "sample variance: %lf\n", v );
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/index.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/index.js
index 9487e47461ee..e48ab79ce477 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/examples/index.js
@@ -18,22 +18,19 @@
'use strict';
-var randu = require( '@stdlib/random/base/randu' );
-var round = require( '@stdlib/math/base/special/round' );
-var Float64Array = require( '@stdlib/array/float64' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var filledarrayBy = require( '@stdlib/array/filled-by' );
+var bernoulli = require( '@stdlib/random/base/bernoulli' );
var dnanvariancepn = require( './../lib' );
-var x;
-var i;
-
-x = new Float64Array( 10 );
-for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- x[ i ] = round( (randu()*100.0) - 50.0 );
+function rand() {
+ if ( bernoulli( 0.8 ) < 1 ) {
+ return NaN;
}
+ return uniform( -50.0, 50.0 );
}
+
+var x = filledarrayBy( 10, 'float64', rand );
console.log( x );
var v = dnanvariancepn( x.length, 1, x, 1 );
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/include/stdlib/stats/base/dnanvariancepn.h b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/include/stdlib/stats/base/dnanvariancepn.h
index 852e2dfe777e..8ad23b4ebb2a 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/include/stdlib/stats/base/dnanvariancepn.h
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/include/stdlib/stats/base/dnanvariancepn.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_STATS_BASE_DNANVARIANCEPN_H
#define STDLIB_STATS_BASE_DNANVARIANCEPN_H
-#include
+#include "stdlib/blas/base/shared.h"
/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
@@ -31,7 +31,12 @@ extern "C" {
/**
* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
*/
-double stdlib_strided_dnanvariancepn( const int64_t N, const double correction, const double *X, const int64_t stride );
+double API_SUFFIX(stdlib_strided_dnanvariancepn)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX );
+
+/**
+* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
+*/
+double API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnansumpw.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnansumpw.js
deleted file mode 100644
index 46988a3c2679..000000000000
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnansumpw.js
+++ /dev/null
@@ -1,185 +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 floor = require( '@stdlib/math/base/special/floor' );
-
-
-// VARIABLES //
-
-// Blocksize for pairwise summation (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.):
-var BLOCKSIZE = 128;
-
-
-// MAIN //
-
-/**
-* Computes the sum of a double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation.
-*
-* ## Method
-*
-* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.
-*
-* ## References
-*
-* - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).
-*
-* @private
-* @param {PositiveInteger} N - number of indexed elements
-* @param {NumericArray} out - two-element output array whose first element is the accumulated sum and whose second element is the accumulated number of summed values
-* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
-* @param {NonNegativeInteger} offset - starting index
-* @returns {NumericArray} output array
-*
-* @example
-* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
-*
-* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
-*
-* var out = [ 0.0, 0 ];
-* var v = dnansumpw( N, out, x, 2, 1 );
-* // returns [ 5.0, 4 ]
-*/
-function dnansumpw( N, out, x, stride, offset ) {
- var ix;
- var s0;
- var s1;
- var s2;
- var s3;
- var s4;
- var s5;
- var s6;
- var s7;
- var M;
- var s;
- var n;
- var v;
- var i;
-
- ix = offset;
- if ( N < 8 ) {
- // Use simple summation...
- s = 0.0;
- n = 0;
- for ( i = 0; i < N; i++ ) {
- v = x[ ix ];
- if ( v === v ) {
- s += v;
- n += 1;
- }
- ix += stride;
- }
- out[ 0 ] += s;
- out[ 1 ] += n;
- return out;
- }
- if ( N <= BLOCKSIZE ) {
- // Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...
- s0 = 0.0;
- s1 = 0.0;
- s2 = 0.0;
- s3 = 0.0;
- s4 = 0.0;
- s5 = 0.0;
- s6 = 0.0;
- s7 = 0.0;
- n = 0;
-
- M = N % 8;
- for ( i = 0; i < N-M; i += 8 ) {
- v = x[ ix ];
- if ( v === v ) {
- s0 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s1 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s2 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s3 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s4 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s5 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s6 += v;
- n += 1;
- }
- ix += stride;
- v = x[ ix ];
- if ( v === v ) {
- s7 += v;
- n += 1;
- }
- ix += stride;
- }
- // Pairwise sum the accumulators:
- s = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
-
- // Clean-up loop...
- for ( i; i < N; i++ ) {
- v = x[ ix ];
- if ( v === v ) {
- s += v;
- n += 1;
- }
- ix += stride;
- }
- out[ 0 ] += s;
- out[ 1 ] += n;
- return out;
- }
- // Recurse by dividing by two, but avoiding non-multiples of unroll factor...
- n = floor( N/2 );
- n -= n % 8;
- return dnansumpw( n, out, x, stride, ix ) + dnansumpw( N-n, out, x, stride, ix+(n*stride) ); // eslint-disable-line max-len
-}
-
-
-// EXPORTS //
-
-module.exports = dnansumpw;
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.js
index 903162954441..73a686d31ff0 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.js
@@ -20,12 +20,8 @@
// MODULES //
-var dnansumpw = require( './dnansumpw.js' );
-
-
-// VARIABLES //
-
-var WORKSPACE = [ 0.0, 0 ];
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -45,68 +41,19 @@ var WORKSPACE = [ 0.0, 0 ];
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
-* var N = x.length;
*
-* var v = dnanvariancepn( N, 1, x, 1 );
+* var v = dnanvariancepn( x.length, 1, x, 1 );
* // returns ~4.3333
*/
-function dnanvariancepn( N, correction, x, stride ) {
- var mu;
- var ix;
- var M2;
- var nc;
- var M;
- var d;
- var v;
- var n;
- var i;
-
- if ( N <= 0 ) {
- return NaN;
- }
- if ( N === 1 || stride === 0 ) {
- v = x[ 0 ];
- if ( v === v && N-correction > 0.0 ) {
- return 0.0;
- }
- return NaN;
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- // Compute an estimate for the mean...
- WORKSPACE[ 0 ] = 0.0;
- WORKSPACE[ 1 ] = 0;
- dnansumpw( N, WORKSPACE, x, stride, ix );
- n = WORKSPACE[ 1 ];
- nc = n - correction;
- if ( nc <= 0.0 ) {
- return NaN;
- }
- mu = WORKSPACE[ 0 ] / n;
-
- // Compute the variance...
- M2 = 0.0;
- M = 0.0;
- for ( i = 0; i < N; i++ ) {
- v = x[ ix ];
- if ( v === v ) {
- d = v - mu;
- M2 += d * d;
- M += d;
- }
- ix += stride;
- }
- return (M2/nc) - ((M/n)*(M/nc));
+function dnanvariancepn( N, correction, x, strideX ) {
+ return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.native.js
index 2c5bdb7a5bcb..004c519526ff 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/dnanvariancepn.native.js
@@ -31,20 +31,19 @@ var addon = require( './../src/addon.node' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} x - input array
-* @param {integer} stride - stride length
+* @param {integer} strideX - stride length
* @returns {number} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
-* var N = x.length;
*
-* var v = dnanvariancepn( N, 1, x, 1 );
+* var v = dnanvariancepn( x.length, 1, x, 1 );
* // returns ~4.3333
*/
-function dnanvariancepn( N, correction, x, stride ) {
- return addon( N, correction, x, stride );
+function dnanvariancepn( N, correction, x, strideX ) {
+ return addon( N, correction, x, strideX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/index.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/index.js
index 9573909ea075..2d2bb09d5364 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/index.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/index.js
@@ -28,20 +28,17 @@
* var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' );
*
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
-* var N = x.length;
*
-* var v = dnanvariancepn( N, 1, x, 1 );
+* var v = dnanvariancepn( x.length, 1, x, 1 );
* // returns ~4.3333
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
* var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
*
-* var v = dnanvariancepn.ndarray( N, 1, x, 2, 1 );
+* var v = dnanvariancepn.ndarray( 5, 1, x, 2, 1 );
* // returns 6.25
*/
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.js
index 8f191ce6329f..18cb4c72b2a1 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.js
@@ -20,7 +20,7 @@
// MODULES //
-var dnansumpw = require( './dnansumpw.js' );
+var dnannsumpw = require( '@stdlib/blas/ext/base/dnannsumpw' ).ndarray;
// VARIABLES //
@@ -45,21 +45,19 @@ var WORKSPACE = [ 0.0, 0 ];
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} 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} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
*
-* var v = dnanvariancepn( N, 1, x, 2, 1 );
+* var v = dnanvariancepn( 5, 1, x, 2, 1 );
* // returns 6.25
*/
-function dnanvariancepn( N, correction, x, stride, offset ) {
+function dnanvariancepn( N, correction, x, strideX, offsetX ) {
var mu;
var ix;
var M2;
@@ -73,8 +71,8 @@ function dnanvariancepn( N, correction, x, stride, offset ) {
if ( N <= 0 ) {
return NaN;
}
- if ( N === 1 || stride === 0 ) {
- v = x[ offset ];
+ if ( N === 1 || strideX === 0 ) {
+ v = x[ offsetX ];
if ( v === v && N-correction > 0.0 ) {
return 0.0;
}
@@ -83,7 +81,7 @@ function dnanvariancepn( N, correction, x, stride, offset ) {
// Compute an estimate for the mean...
WORKSPACE[ 0 ] = 0.0;
WORKSPACE[ 1 ] = 0;
- dnansumpw( N, WORKSPACE, x, stride, offset );
+ dnannsumpw( N, x, strideX, offsetX, WORKSPACE, 1, 0 );
n = WORKSPACE[ 1 ];
nc = n - correction;
if ( nc <= 0.0 ) {
@@ -92,7 +90,7 @@ function dnanvariancepn( N, correction, x, stride, offset ) {
mu = WORKSPACE[ 0 ] / n;
// Compute the variance...
- ix = offset;
+ ix = offsetX;
M2 = 0.0;
M = 0.0;
for ( i = 0; i < N; i++ ) {
@@ -102,7 +100,7 @@ function dnanvariancepn( N, correction, x, stride, offset ) {
M2 += d * d;
M += d;
}
- ix += stride;
+ ix += strideX;
}
return (M2/nc) - ((M/n)*(M/nc));
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.native.js
index d9c7b94fa746..41228aad6f93 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/lib/ndarray.native.js
@@ -20,8 +20,7 @@
// MODULES //
-var Float64Array = require( '@stdlib/array/float64' );
-var addon = require( './dnanvariancepn.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,27 +31,20 @@ var addon = require( './dnanvariancepn.native.js' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} correction - degrees of freedom adjustment
* @param {Float64Array} 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} variance
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
-* var floor = require( '@stdlib/math/base/special/floor' );
*
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
-* var N = floor( x.length / 2 );
*
-* var v = dnanvariancepn( N, 1, x, 2, 1 );
+* var v = dnanvariancepn( 5, 1, x, 2, 1 );
* // returns 6.25
*/
-function dnanvariancepn( N, correction, x, stride, offset ) {
- var view;
- if ( stride < 0 ) {
- offset += (N-1) * stride;
- }
- view = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
- return addon( N, correction, view, stride );
+function dnanvariancepn( N, correction, x, strideX, offsetX ) {
+ return addon.ndarray( N, correction, x, strideX, offsetX );
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/manifest.json b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/manifest.json
index 078ba0d29817..ddb23a2b34e7 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/manifest.json
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/manifest.json
@@ -1,5 +1,8 @@
{
- "options": {},
+ "options": {
+ "task": "build",
+ "wasm": false
+ },
"fields": [
{
"field": "src",
@@ -25,52 +28,77 @@
"confs": [
{
"task": "build",
+ "wasm": false,
"src": [
- "./src/dnanvariancepn.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/strided/base/stride2offset",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-double",
+ "@stdlib/blas/ext/base/dnannsumpw",
"@stdlib/napi/argv-strided-float64array",
"@stdlib/napi/create-double"
]
},
{
"task": "benchmark",
+ "wasm": false,
"src": [
- "./src/dnanvariancepn.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/blas/ext/base/dnannsumpw",
+ "@stdlib/strided/base/stride2offset"
+ ]
},
{
"task": "examples",
+ "wasm": false,
"src": [
- "./src/dnanvariancepn.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
+ "libraries": [],
+ "libpath": [],
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/blas/ext/base/dnannsumpw",
+ "@stdlib/strided/base/stride2offset"
+ ]
+ },
+ {
+ "task": "",
+ "wasm": true,
+ "src": [
+ "./src/main.c"
],
+ "include": [
+ "./include"
+ ],
+ "libraries": [],
"libpath": [],
- "dependencies": []
+ "dependencies": [
+ "@stdlib/blas/base/shared",
+ "@stdlib/blas/ext/base/dnannsumpw",
+ "@stdlib/strided/base/stride2offset"
+ ]
}
]
}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/addon.c b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/addon.c
index 8c95a6675498..85ad079b6e30 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/addon.c
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/addon.c
@@ -17,6 +17,7 @@
*/
#include "stdlib/stats/base/dnanvariancepn.h"
+#include "stdlib/blas/base/shared.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_int64.h"
@@ -35,11 +36,29 @@
static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
- STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 );
- STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 2 );
- STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dnanvariancepn( N, correction, X, stride ), v );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 )
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvariancepn)( N, correction, X, strideX ), v );
return v;
}
-STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
+/**
+* Receives JavaScript callback invocation data.
+*
+* @param env environment under which the function is invoked
+* @param info callback data
+* @return Node-API value
+*/
+static napi_value addon_method( napi_env env, napi_callback_info info ) {
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
+ STDLIB_NAPI_ARGV_DOUBLE( env, correction, argv, 1 );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
+ STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( N, correction, X, strideX, offsetX ), v );
+ return v;
+}
+
+STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/dnanvariancepn.c b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/dnanvariancepn.c
deleted file mode 100644
index f2ee669c48f7..000000000000
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/dnanvariancepn.c
+++ /dev/null
@@ -1,239 +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.
-*/
-
-#include "stdlib/stats/base/dnanvariancepn.h"
-#include
-
-/**
-* Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation.
-*
-* ## Method
-*
-* - This implementation uses pairwise summation, which accrues rounding error `O(log2 N)` instead of `O(N)`. The recursion depth is also `O(log2 N)`.
-*
-* ## References
-*
-* - Higham, Nicholas J. 1993. "The Accuracy of Floating Point Summation." _SIAM Journal on Scientific Computing_ 14 (4): 783–99. doi:[10.1137/0914050](https://doi.org/10.1137/0914050).
-*
-* @param N number of indexed elements
-* @param W two-element output array
-* @param X input array
-* @param stride stride length
-* @return output value
-*/
-static void dnansumpw( const int64_t N, double *W, const double *X, const int64_t stride ) {
- double *xp1;
- double *xp2;
- double sum;
- int64_t ix;
- int64_t M;
- int64_t n;
- int64_t i;
- double s0;
- double s1;
- double s2;
- double s3;
- double s4;
- double s5;
- double s6;
- double s7;
- double v;
-
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- if ( N < 8 ) {
- // Use simple summation...
- sum = 0.0;
- n = 0;
- for ( i = 0; i < N; i++ ) {
- v = X[ ix ];
- if ( v == v ) {
- sum += X[ ix ];
- n += 1;
- }
- ix += stride;
- }
- W[ 0 ] += sum;
- W[ 1 ] += n;
- return;
- }
- // Blocksize for pairwise summation: 128 (NOTE: decreasing the blocksize decreases rounding error as more pairs are summed, but also decreases performance. Because the inner loop is unrolled eight times, the blocksize is effectively `16`.)
- if ( N <= 128 ) {
- // Sum a block with 8 accumulators (by loop unrolling, we lower the effective blocksize to 16)...
- s0 = 0.0;
- s1 = 0.0;
- s2 = 0.0;
- s3 = 0.0;
- s4 = 0.0;
- s5 = 0.0;
- s6 = 0.0;
- s7 = 0.0;
- n = 0;
-
- M = N % 8;
- for ( i = 0; i < N-M; i += 8 ) {
- v = X[ ix ];
- if ( v == v ) {
- s0 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s1 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s2 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s3 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s4 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s5 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s6 += v;
- n += 1;
- }
- ix += stride;
- v = X[ ix ];
- if ( v == v ) {
- s7 += v;
- n += 1;
- }
- ix += stride;
- }
- // Pairwise sum the accumulators:
- sum = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
-
- // Clean-up loop...
- for (; i < N; i++ ) {
- v = X[ ix ];
- if ( v == v ) {
- sum += X[ ix ];
- n += 1;
- }
- ix += stride;
- }
- W[ 0 ] += sum;
- W[ 1 ] += n;
- return;
- }
- // Recurse by dividing by two, but avoiding non-multiples of unroll factor...
- n = N / 2;
- n -= n % 8;
- if ( stride < 0 ) {
- xp1 = (double *)X + ( (n-N)*stride );
- xp2 = (double *)X;
- } else {
- xp1 = (double *)X;
- xp2 = (double *)X + ( n*stride );
- }
- dnansumpw( n, W, xp1, stride );
- dnansumpw( N-n, W, xp2, stride );
-}
-
-/**
-* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
-*
-* ## Method
-*
-* - This implementation uses a two-pass approach, as suggested by Neely (1966).
-*
-* ## References
-*
-* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
-* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
-*
-* @param N number of indexed elements
-* @param correction degrees of freedom adjustment
-* @param X input array
-* @param stride stride length
-* @return output value
-*/
-double stdlib_strided_dnanvariancepn( const int64_t N, const double correction, const double *X, const int64_t stride ) {
- double W[] = { 0.0, 0.0 };
- int64_t ix;
- int64_t i;
- double mu;
- double M2;
- double nc;
- double M;
- double n;
- double d;
- double v;
-
- if ( N <= 0 ) {
- return 0.0 / 0.0; // NaN
- }
- if ( N == 1 || stride == 0 ) {
- v = X[ 0 ];
- if ( v == v && (double)N-correction > 0.0 ) {
- return 0.0;
- }
- return 0.0 / 0.0; // NaN
- }
- // Compute an estimate for the mean...
- dnansumpw( N, W, X, stride );
- n = W[ 1 ];
- nc = n - correction;
- if ( nc <= 0.0 ) {
- return 0.0 / 0.0; // NaN
- }
- if ( stride < 0 ) {
- ix = (1-N) * stride;
- } else {
- ix = 0;
- }
- mu = W[ 0 ] / n;
-
- // Compute the variance...
- M2 = 0.0;
- M = 0.0;
- for ( i = 0; i < N; i++ ) {
- v = X[ ix ];
- if ( v == v ) {
- d = v - mu;
- M2 += d * d;
- M += d;
- }
- ix += stride;
- }
- return (M2/nc) - ((M/n)*(M/nc));
-}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/main.c b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/main.c
new file mode 100644
index 000000000000..f1c8c3a2b479
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/src/main.c
@@ -0,0 +1,101 @@
+/**
+* @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.
+*/
+
+#include "stdlib/stats/base/dnanvariancepn.h"
+#include "stdlib/blas/ext/base/dnannsumpw.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
+
+/**
+* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
+*
+* ## Method
+*
+* - This implementation uses a two-pass approach, as suggested by Neely (1966).
+*
+* ## References
+*
+* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
+* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
+*
+* @param N number of indexed elements
+* @param correction degrees of freedom adjustment
+* @param X input array
+* @param stridex stride length
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dnanvariancepn)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ) {
+ const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ return API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( N, correction, X, strideX, ox );
+}
+
+/**
+* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param correction degrees of freedom adjustment
+* @param X input array
+* @param strideX stride length
+* @param offsetX starting index for X
+* @return output value
+*/
+double API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
+ CBLAS_INT ix;
+ CBLAS_INT i;
+ CBLAS_INT n;
+ double sum;
+ double mu;
+ double M2;
+ double nc;
+ double M;
+ double d;
+ double v;
+
+ if ( N <= 0 ) {
+ return 0.0 / 0.0; // NaN
+ }
+ if ( N == 1 || strideX == 0 ) {
+ v = X[ 0 ];
+ if ( v == v && (double)N-correction > 0.0 ) {
+ return 0.0;
+ }
+ return 0.0 / 0.0; // NaN
+ }
+ // Compute an estimate for the mean...
+ sum = API_SUFFIX(stdlib_strided_dnannsumpw_ndarray)( N, X, strideX, offsetX, &n );
+ nc = (double)n - correction;
+ if ( nc <= 0.0 ) {
+ return 0.0 / 0.0; // NaN
+ }
+ ix = offsetX;
+ mu = sum / (double)n;
+
+ // Compute the variance...
+ M2 = 0.0;
+ M = 0.0;
+ for ( i = 0; i < N; i++ ) {
+ v = X[ ix ];
+ if ( v == v ) {
+ d = v - mu;
+ M2 += d * d;
+ M += d;
+ }
+ ix += strideX;
+ }
+ return (M2/nc) - ((M/(double)n)*(M/nc));
+}
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.js
index edd5606a6beb..809bfe9e6702 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.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 Float64Array = require( '@stdlib/array/float64' );
var dnanvariancepn = require( './../lib/dnanvariancepn.js' );
@@ -213,7 +212,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -230,15 +228,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, 2 );
+ v = dnanvariancepn( 5, 1, x, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
var i;
@@ -255,9 +251,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, -2 );
+ v = dnanvariancepn( 5, 1, x, -2 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -295,7 +290,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -313,9 +307,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 = dnanvariancepn( N, 1, x1, 2 );
+ v = dnanvariancepn( 5, 1, x1, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.native.js
index 0e25d2f49446..21c9f75a9a85 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.dnanvariancepn.native.js
@@ -22,7 +22,6 @@
var resolve = require( 'path' ).resolve;
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 tryRequire = require( '@stdlib/utils/try-require' );
@@ -222,7 +221,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -239,15 +237,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, 2 );
+ v = dnanvariancepn( 5, 1, x, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
var i;
@@ -264,9 +260,8 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, -2 );
+ v = dnanvariancepn( 5, 1, x, -2 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -304,7 +299,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
tape( 'the function supports view offsets', opts, function test( t ) {
var x0;
var x1;
- var N;
var v;
x0 = new Float64Array([
@@ -322,9 +316,8 @@ tape( 'the function supports view offsets', opts, function test( t ) {
]);
x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
- N = floor(x1.length / 2);
- v = dnanvariancepn( N, 1, x1, 2 );
+ v = dnanvariancepn( 5, 1, x1, 2 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.js
index ead3999c04a1..94ec373a067f 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/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 Float64Array = require( '@stdlib/array/float64' );
var dnanvariancepn = require( './../lib/ndarray.js' );
@@ -213,7 +212,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -230,15 +228,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, 2, 0 );
+ v = dnanvariancepn( 5, 1, x, 2, 0 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', function test( t ) {
- var N;
var x;
var v;
var i;
@@ -255,9 +251,8 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, -2, 8 );
+ v = dnanvariancepn( 5, 1, x, -2, 8 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -293,7 +288,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
});
tape( 'the function supports an `offset` parameter', function test( t ) {
- var N;
var x;
var v;
@@ -309,9 +303,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
NaN,
NaN // 4
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, 2, 1 );
+ v = dnanvariancepn( 5, 1, x, 2, 1 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.native.js
index 93d05f14a494..5a80601b2f3d 100644
--- a/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.native.js
+++ b/lib/node_modules/@stdlib/stats/base/dnanvariancepn/test/test.ndarray.native.js
@@ -22,7 +22,6 @@
var resolve = require( 'path' ).resolve;
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 tryRequire = require( '@stdlib/utils/try-require' );
@@ -222,7 +221,6 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
});
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -239,15 +237,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
NaN
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, 2, 0 );
+ v = dnanvariancepn( 5, 1, x, 2, 0 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();
});
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
- var N;
var x;
var v;
var i;
@@ -264,9 +260,8 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
4.0, // 0
2.0
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, -2, 8 );
+ v = dnanvariancepn( 5, 1, x, -2, 8 );
t.strictEqual( v, 6.25, 'returns expected value' );
x = new Float64Array( 1e3 );
@@ -302,7 +297,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
});
tape( 'the function supports an `offset` parameter', opts, function test( t ) {
- var N;
var x;
var v;
@@ -318,9 +312,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) {
NaN,
NaN // 4
]);
- N = floor( x.length / 2 );
- v = dnanvariancepn( N, 1, x, 2, 1 );
+ v = dnanvariancepn( 5, 1, x, 2, 1 );
t.strictEqual( v, 6.25, 'returns expected value' );
t.end();