diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/README.md b/lib/node_modules/@stdlib/stats/base/dnanvariance/README.md index 9b125e03d9c2..6bac8378bd9c 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/README.md +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/README.md @@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var dnanvariance = require( '@stdlib/stats/base/dnanvariance' ); ``` -#### dnanvariance( N, correction, x, stride ) +#### dnanvariance( N, correction, x, strideX ) -Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values. +Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -116,41 +116,38 @@ 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 ] ); -var v = dnanvariance( N, 1, x, 2 ); +var v = dnanvariance( 5, 1, x, 2 ); // returns 6.25 ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. - + ```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 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = dnanvariance( N, 1, x1, 2 ); +var v = dnanvariance( 5, 1, x1, 2 ); // returns 6.25 ``` -#### dnanvariance.ndarray( N, correction, x, stride, offset ) +#### dnanvariance.ndarray( N, correction, x, strideX, offsetX ) -Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using alternative indexing semantics. +Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -163,18 +160,18 @@ var v = dnanvariance.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 element in `x` starting from the second element -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 + ```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 ] ); -var v = dnanvariance.ndarray( N, 1, x, 2, 1 ); +var v = dnanvariance.ndarray( 5, 1, x, 2, 1 ); // returns 6.25 ``` @@ -200,18 +197,19 @@ var v = dnanvariance.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 dnanvariance = require( '@stdlib/stats/base/dnanvariance' ); -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 = dnanvariance( x.length, 1, x, 1 ); @@ -222,6 +220,125 @@ console.log( v ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dnanvariance.h" +``` + +#### stdlib_strided_dnanvariance( N, correction, \*X, strideX ) + +Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values. + +```c +const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; + +double v = stdlib_strided_dnanvariance( 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_dnanvariance( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_dnanvariance_ndarray( N, correction, \*X, strideX, offsetX ) + +Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics. + +```c +const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; + +double v = stdlib_strided_dnanvariance_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_dnanvariance_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/dnanvariance.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_dnanvariance( N, 1.0, x, strideX ); + + // Print the result: + printf( "sample variance: %lf\n", v ); +} +``` + +
+ + + +
+ + +
diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.js index d9a4d9e76d07..ac5a46043f47 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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 dnanvariance = require( './../lib/dnanvariance.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 dnanvariance = require( './../lib/dnanvariance.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/dnanvariance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.native.js index bf78c30f9d31..36b4add230c7 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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/dnanvariance/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.ndarray.js index 94926c91a30f..9edb4ab1122d 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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 dnanvariance = 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 dnanvariance = 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/dnanvariance/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.ndarray.native.js index edd833823e73..bc51028c025d 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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/dnanvariance/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/c/benchmark.length.c index fa2512e14203..351f8629ebcc 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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_dnanvariance( 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_dnanvariance_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/dnanvariance/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dnanvariance/docs/repl.txt index ab3ad6e335d2..72ea56e1862e 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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. - 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 alternative indexing semantics. @@ -93,10 +90,10 @@ x: Float64Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -112,9 +109,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/dnanvariance/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dnanvariance/docs/types/index.d.ts index 7bb2784d86fb..8ba39bcd9070 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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 = dnanvariance( 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 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 = dnanvariance.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/dnanvariance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dnanvariance/examples/c/example.c index 0ad819ac00f1..823b22cacffb 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/dnanvariance.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_dnanvariance( N, 1, x, stride ); + double v = stdlib_strided_dnanvariance( N, 1.0, x, strideX ); // Print the result: printf( "sample variance: %lf\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/examples/index.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/examples/index.js index 83755ce2d7fd..83a8e5dc2385 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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 dnanvariance = 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 = dnanvariance( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/include/stdlib/stats/base/dnanvariance.h b/lib/node_modules/@stdlib/stats/base/dnanvariance/include/stdlib/stats/base/dnanvariance.h index b78e0d61d149..61fa856fd812 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/include/stdlib/stats/base/dnanvariance.h +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/include/stdlib/stats/base/dnanvariance.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_DNANVARIANCE_H #define STDLIB_STATS_BASE_DNANVARIANCE_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. @@ -29,9 +29,14 @@ extern "C" { #endif /** -* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values. +* Computes the variance of a double-precision floating-point strided array, ignoring `NaN` values. */ -double stdlib_strided_dnanvariance( const int64_t N, const double correction, const double *X, const int64_t stride ); +double API_SUFFIX(stdlib_strided_dnanvariance)( 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 alternative indexing semantics. +*/ +double API_SUFFIX(stdlib_strided_dnanvariance_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/dnanvariance/lib/dnanvariance.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.js index dc433d62c2ef..c9c3c5227fd4 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.js @@ -20,7 +20,8 @@ // MODULES // -var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -31,20 +32,19 @@ var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' ); * @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 = dnanvariance( N, 1, x, 1 ); +* var v = dnanvariance( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function dnanvariance( N, correction, x, stride ) { - return dnanvariancepn( N, correction, x, stride ); +function dnanvariance( N, correction, x, strideX ) { + return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.native.js index 1e89d602c53e..ad3d7b4ddf9c 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/dnanvariance.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 = dnanvariance( N, 1, x, 1 ); +* var v = dnanvariance( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function dnanvariance( N, correction, x, stride ) { - return addon( N, correction, x, stride ); +function dnanvariance( N, correction, x, strideX ) { + return addon( N, correction, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/index.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/index.js index 47949c9cc894..285b59e96e18 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/index.js @@ -28,20 +28,17 @@ * var dnanvariance = require( '@stdlib/stats/base/dnanvariance' ); * * var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = dnanvariance( N, 1, x, 1 ); +* var v = dnanvariance( x.length, 1, x, 1 ); * // returns ~4.3333 * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dnanvariance = require( '@stdlib/stats/base/dnanvariance' ); * * 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 = dnanvariance.ndarray( N, 1, x, 2, 1 ); +* var v = dnanvariance.ndarray( 5, 1, x, 2, 1 ); * // returns 6.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.js index 78e383cc31b1..e2433522e480 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.js @@ -31,22 +31,20 @@ var dnanvariancepn = require( '@stdlib/stats/base/dnanvariancepn' ).ndarray; * @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 = dnanvariance( N, 1, x, 2, 1 ); +* var v = dnanvariance( 5, 1, x, 2, 1 ); * // returns 6.25 */ -function dnanvariance( N, correction, x, stride, offset ) { - return dnanvariancepn( N, correction, x, stride, offset ); +function dnanvariance( N, correction, x, strideX, offsetX ) { + return dnanvariancepn( N, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.native.js index 6eb4a0ba435f..da5963fbc607 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); -var addon = require( './dnanvariance.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,27 +31,20 @@ var addon = require( './dnanvariance.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 = dnanvariance( N, 1, x, 2, 1 ); +* var v = dnanvariance( 5, 1, x, 2, 1 ); * // returns 6.25 */ -function dnanvariance( 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 dnanvariance( N, correction, x, strideX, offsetX ) { + return addon.ndarray( N, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/manifest.json b/lib/node_modules/@stdlib/stats/base/dnanvariance/manifest.json index ca135dfb5608..b30178050e39 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,17 +28,18 @@ "confs": [ { "task": "build", + "wasm" : false, "src": [ - "./src/dnanvariance.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/stats/base/dnanvariancepn", "@stdlib/napi/export", "@stdlib/napi/argv", @@ -49,33 +51,52 @@ }, { "task": "benchmark", + "wasm" : false, "src": [ - "./src/dnanvariance.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/stats/base/dnanvariancepn" ] }, { "task": "examples", + "wasm" : false, "src": [ - "./src/dnanvariance.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/stats/base/dnanvariancepn" + ] + }, + { + "task": "build", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", "@stdlib/stats/base/dnanvariancepn" ] } diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/src/addon.c b/lib/node_modules/@stdlib/stats/base/dnanvariance/src/addon.c index ed817df01bed..b00fd7060521 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/src/addon.c @@ -17,6 +17,7 @@ */ #include "stdlib/stats/base/dnanvariance.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_dnanvariance( 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_dnanvariance)( 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_dnanvariance_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/dnanvariance/src/dnanvariance.c b/lib/node_modules/@stdlib/stats/base/dnanvariance/src/dnanvariance.c deleted file mode 100644 index 13375cf0580d..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/src/dnanvariance.c +++ /dev/null @@ -1,34 +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/dnanvariance.h" -#include "stdlib/stats/base/dnanvariancepn.h" -#include - -/** -* Computes the variance of a double-precision floating-point strided array ignoring `NaN` values. -* -* @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_dnanvariance( const int64_t N, const double correction, const double *X, const int64_t stride ) { - return stdlib_strided_dnanvariancepn( N, correction, X, stride ); -} diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/src/main.c b/lib/node_modules/@stdlib/stats/base/dnanvariance/src/main.c new file mode 100644 index 000000000000..d0841a9111b4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/src/main.c @@ -0,0 +1,50 @@ +/** +* @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/dnanvariance.h" +#include "stdlib/stats/base/dnanvariancepn.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. +* +* @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_dnanvariance)( 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 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_dnanvariance_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + return API_SUFFIX(stdlib_strided_dnanvariancepn_ndarray)( N, correction, X, strideX, offsetX ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.js index 2ca3f359486f..ba861d5e0773 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.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 dnanvariance = require( './../lib/dnanvariance.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 = dnanvariance( N, 1, x, 2 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x, -2 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x1, 2 ); + v = dnanvariance( 5, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.native.js index 5e485cb85641..1c24bf5141b2 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.dnanvariance.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 = dnanvariance( N, 1, x, 2 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x, -2 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x1, 2 ); + v = dnanvariance( 5, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.ndarray.js index 3e8dffe868f7..fdfbdb552e91 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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 dnanvariance = 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 = dnanvariance( N, 1, x, 2, 0 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x, -2, 8 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x, 2, 1 ); + v = dnanvariance( 5, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.ndarray.native.js index 3c6dc17258f4..6a525ab58914 100644 --- a/lib/node_modules/@stdlib/stats/base/dnanvariance/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dnanvariance/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 = dnanvariance( N, 1, x, 2, 0 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x, -2, 8 ); + v = dnanvariance( 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 = dnanvariance( N, 1, x, 2, 1 ); + v = dnanvariance( 5, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end();