diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/README.md b/lib/node_modules/@stdlib/stats/base/dvarianceyc/README.md index ba7635b8d142..9f79f8b49dfe 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/README.md @@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var dvarianceyc = require( '@stdlib/stats/base/dvarianceyc' ); ``` -#### dvarianceyc( N, correction, x, stride ) +#### dvarianceyc( N, correction, x, strideX ) Computes the [variance][variance] of a double-precision floating-point strided array `x` using a one-pass algorithm proposed by Youngs and Cramer. @@ -106,9 +106,8 @@ Computes the [variance][variance] of a double-precision floating-point strided a var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = dvarianceyc( N, 1, x, 1 ); +var v = dvarianceyc( x.length, 1, x, 1 ); // returns ~4.3333 ``` @@ -117,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. 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 ] ); -var N = floor( x.length / 2 ); -var v = dvarianceyc( N, 1, x, 2 ); +var v = dvarianceyc( 4, 1, x, 2 ); // returns 6.25 ``` @@ -138,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 ] ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = dvarianceyc( N, 1, x1, 2 ); +var v = dvarianceyc( 4, 1, x1, 2 ); // returns 6.25 ``` -#### dvarianceyc.ndarray( N, correction, x, stride, offset ) +#### dvarianceyc.ndarray( N, correction, x, strideX, offsetX ) Computes the [variance][variance] of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. @@ -157,26 +151,23 @@ Computes the [variance][variance] of a double-precision floating-point strided a var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = dvarianceyc.ndarray( N, 1, x, 1, 0 ); +var v = dvarianceyc.ndarray( x.length, 1, x, 1, 0 ); // returns ~4.33333 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [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 v = dvarianceyc.ndarray( N, 1, x, 2, 1 ); +var v = dvarianceyc.ndarray( 4, 1, x, 2, 1 ); // returns 6.25 ``` @@ -202,18 +193,12 @@ var v = dvarianceyc.ndarray( N, 1, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dvarianceyc = require( '@stdlib/stats/base/dvarianceyc' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); var v = dvarianceyc( x.length, 1, x, 1 ); @@ -224,6 +209,125 @@ console.log( v ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dvarianceyc.h" +``` + +#### stdlib_strided_dvarianceyc( N, correction, \*X, strideX ) + +Computes the [variance][variance] of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. + +```c +const double x[] = { 1.0, -2.0, 2.0 }; + +double v = stdlib_strided_dvarianceyc( 3, 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. 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_dvarianceyc( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_dvarianceyc_ndarray( N, correction, \*X, strideX, offsetX ) + +Computes the [variance][variance] of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. + +```c +const double x[] = { 1.0, -2.0, 2.0 }; + +double v = stdlib_strided_dvarianceyc_ndarray( 3, 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. 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_dvarianceyc_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/dvarianceyc.h" +#include + +int main( void ) { + // Create a strided array: + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify the stride length: + const int strideX = 2; + + // Compute the variance: + double v = stdlib_strided_dvarianceyc( N, 1, x, strideX ); + + // Print the result: + printf( "sample variance: %lf\n", v ); +} +``` + +
+ + + +
+ + + * * *
diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.js index b54c56dea28f..470d8d26b207 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dvarianceyc = require( './../lib/dvarianceyc.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -39,13 +45,7 @@ var dvarianceyc = require( './../lib/dvarianceyc.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.native.js index 766f11790923..8ae25a7ab31d 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.native.js @@ -22,10 +22,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +35,9 @@ var dvarianceyc = tryRequire( resolve( __dirname, './../lib/dvarianceyc.native.j var opts = { 'skip': ( dvarianceyc instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -48,13 +50,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++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.js index 5f03d57392e0..0bb722cc980d 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.js @@ -21,14 +21,20 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dvarianceyc = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -39,13 +45,7 @@ var dvarianceyc = 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++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.native.js index 70026bc3363f..d57fbad48a97 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,9 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +35,9 @@ var dvarianceyc = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) var opts = { 'skip': ( dvarianceyc instanceof Error ) }; +var options = { + 'dtype': 'float64' +}; // FUNCTIONS // @@ -48,13 +50,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++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = uniform( len, -10.0, 10.0, options ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/c/benchmark.length.c index 9fd04b2942de..96da50370957 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/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; @@ -107,6 +107,7 @@ static double benchmark( int iterations, int len ) { v = 0.0; t = tic(); for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar v = stdlib_strided_dvarianceyc( len, 1.0, x, 1 ); if ( v != v ) { printf( "should not return NaN\n" ); @@ -120,6 +121,40 @@ 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++ ) { + 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_dvarianceyc_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 +177,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/dvarianceyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dvarianceyc/docs/repl.txt index 13e416059d54..d0cd7cc21ef1 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/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 using a one-pass algorithm proposed by Youngs and Cramer. - 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. @@ -31,8 +31,8 @@ x: Float64Array Input array. - stride: integer - Index increment. + strideX: integer + Stride Length. Returns ------- @@ -46,22 +46,19 @@ > {{alias}}( x.length, 1, x, 1 ) ~4.3333 - // Using `N` and `stride` parameters: + // 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 ) + > {{alias}}( 3, 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 x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, 1, x1, stride ) + > {{alias}}( 3, 1, x1, 2 ) ~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 using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. @@ -90,10 +87,10 @@ x: Float64Array Input array. - stride: integer - Index increment. + strideX: integer + Stride Length. - offset: integer + offsetX: integer Starting index. Returns @@ -110,8 +107,7 @@ // 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 ) + > {{alias}}.ndarray( 3, 1, x, 2, 1 ) ~4.3333 See Also diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dvarianceyc/docs/types/index.d.ts index d6c181e4855a..01dfc782a622 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/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 = dvarianceyc( 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 using a one-pass algorithm proposed by Youngs and Cramer 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 = dvarianceyc.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/dvarianceyc/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/c/example.c index 5057c582ae99..5cfa15d9faf0 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/dvarianceyc.h" -#include #include int main( void ) { // Create a strided array: - double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; // Specify the number of elements: - int64_t N = 4; + const int N = 4; // Specify the stride length: - int64_t stride = 2; + const int strideX = 2; // Compute the variance: - double v = stdlib_strided_dvarianceyc( N, 1, x, stride ); + double v = stdlib_strided_dvarianceyc( N, 1, x, strideX ); // Print the result: printf( "sample variance: %lf\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/index.js index c6ac20b81713..9a412716dac3 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/examples/index.js @@ -18,18 +18,12 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dvarianceyc = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( (randu()*100.0) - 50.0 ); -} +var x = discreteUniform( 10, -50, 50, { + 'dtype': 'float64' +}); console.log( x ); var v = dvarianceyc( x.length, 1, x, 1 ); diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/include/stdlib/stats/base/dvarianceyc.h b/lib/node_modules/@stdlib/stats/base/dvarianceyc/include/stdlib/stats/base/dvarianceyc.h index 6a78e9124efc..8e46400adeb1 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/include/stdlib/stats/base/dvarianceyc.h +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/include/stdlib/stats/base/dvarianceyc.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_DVARIANCEYC_H #define STDLIB_STATS_BASE_DVARIANCEYC_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 using a one-pass algorithm proposed by Youngs and Cramer. */ -double stdlib_strided_dvarianceyc( const int64_t N, const double correction, const double *X, const int64_t stride ); +double API_SUFFIX(stdlib_strided_dvarianceyc)( 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 using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics. +*/ +double API_SUFFIX(stdlib_strided_dvarianceyc_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/dvarianceyc/lib/dvarianceyc.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.js index 1e5612d8a65a..c8895bd95db6 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.js @@ -18,6 +18,12 @@ 'use strict'; +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + // MAIN // /** @@ -34,50 +40,19 @@ * @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, 2.0 ] ); -* var N = x.length; * -* var v = dvarianceyc( N, 1, x, 1 ); +* var v = dvarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function dvarianceyc( N, correction, x, stride ) { - var sum; - var ix; - var S; - var v; - var d; - var n; - var i; - - n = N - correction; - if ( N <= 0 || n <= 0.0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - return 0.0; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - sum = x[ ix ]; - ix += stride; - S = 0.0; - for ( i = 2; i <= N; i++ ) { - v = x[ ix ]; - sum += v; - d = (i*v) - sum; - S += (1.0/(i*(i-1))) * d * d; - ix += stride; - } - return S / n; +function dvarianceyc( N, correction, x, strideX ) { + return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.native.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.native.js index cc006bf4059e..528d2e7a834a 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/dvarianceyc.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, 2.0 ] ); -* var N = x.length; * -* var v = dvarianceyc( N, 1, x, 1 ); +* var v = dvarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 */ -function dvarianceyc( N, correction, x, stride ) { - return addon( N, correction, x, stride ); +function dvarianceyc( N, correction, x, strideX ) { + return addon( N, correction, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/index.js index a13977a30538..4e877ff357aa 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/index.js @@ -28,20 +28,17 @@ * var dvarianceyc = require( '@stdlib/stats/base/dvarianceyc' ); * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = dvarianceyc( N, 1, x, 1 ); +* var v = dvarianceyc( x.length, 1, x, 1 ); * // returns ~4.3333 * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dvarianceyc = require( '@stdlib/stats/base/dvarianceyc' ); * * 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 v = dvarianceyc.ndarray( N, 1, x, 2, 1 ); +* var v = dvarianceyc.ndarray( 4, 1, x, 2, 1 ); * // returns 6.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.js index 68cebc9719e6..3dad935d833c 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.js @@ -34,21 +34,19 @@ * @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 ] ); -* var N = floor( x.length / 2 ); * -* var v = dvarianceyc( N, 1, x, 2, 1 ); +* var v = dvarianceyc( 4, 1, x, 2, 1 ); * // returns 6.25 */ -function dvarianceyc( N, correction, x, stride, offset ) { +function dvarianceyc( N, correction, x, strideX, offsetX ) { var sum; var ix; var S; @@ -61,18 +59,18 @@ function dvarianceyc( N, correction, x, stride, offset ) { if ( N <= 0 || n <= 0.0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { + if ( N === 1 || strideX === 0 ) { return 0.0; } - sum = x[ offset ]; - ix = offset + stride; + sum = x[ offsetX ]; + ix = offsetX + strideX; S = 0.0; for ( i = 2; i <= N; i++ ) { v = x[ ix ]; sum += v; d = (i*v) - sum; S += (1.0/(i*(i-1))) * d * d; - ix += stride; + ix += strideX; } return S / n; } diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.native.js index 6a91178dae41..56df3eb22e57 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); -var addon = require( './dvarianceyc.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,27 +31,20 @@ var addon = require( './dvarianceyc.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 ] ); -* var N = floor( x.length / 2 ); * -* var v = dvarianceyc( N, 1, x, 2, 1 ); +* var v = dvarianceyc( 4, 1, x, 2, 1 ); * // returns 6.25 */ -function dvarianceyc( 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 dvarianceyc( N, correction, x, strideX, offsetX ) { + return addon.ndarray( N, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/manifest.json b/lib/node_modules/@stdlib/stats/base/dvarianceyc/manifest.json index 8e508090b8c2..86308d31795d 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/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/dvarianceyc.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", @@ -48,31 +50,51 @@ }, { "task": "benchmark", + "wasm": false, "src": [ - "./src/dvarianceyc.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] }, { "task": "examples", + "wasm": false, "src": [ - "./src/dvarianceyc.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "", + "wasm": true, + "src": [ + "./src/main.c" ], + "include": [ + "./include" + ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] } ] } diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/addon.c index f4902bb475e1..fe704664419e 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/addon.c @@ -35,11 +35,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_dvarianceyc( 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, stdlib_strided_dvarianceyc( 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, stdlib_strided_dvarianceyc_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/dvarianceyc/src/dvarianceyc.c b/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/main.c similarity index 54% rename from lib/node_modules/@stdlib/stats/base/dvarianceyc/src/dvarianceyc.c rename to lib/node_modules/@stdlib/stats/base/dvarianceyc/src/main.c index a65f6a63662d..2336144c61eb 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/dvarianceyc.c +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/src/main.c @@ -17,7 +17,8 @@ */ #include "stdlib/stats/base/dvarianceyc.h" -#include +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" /** * Computes the variance of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. @@ -30,16 +31,31 @@ * * - Youngs, Edward A., and Elliot M. Cramer. 1971. "Some Results Relevant to Choice of Sum and Sum-of-Product Algorithms." _Technometrics_ 13 (3): 657–65. doi:[10.1080/00401706.1971.10488826](https://doi.org/10.1080/00401706.1971.10488826). * -* @param N number of indexed elements -* @param correction degrees of freedom adjustment -* @param X input array -* @param stride stride length -* @return output value +* @param N number of indexed elements +* @param correction degrees of freedom adjustment +* @param X input array +* @param strideX stride length +* @return output value */ -double stdlib_strided_dvarianceyc( const int64_t N, const double correction, const double *X, const int64_t stride ) { +double API_SUFFIX(stdlib_strided_dvarianceyc)( 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_dvarianceyc_ndarray)( N, correction, X, strideX, ox ); +} + +/** +* Computes the variance of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer 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_dvarianceyc_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; double sum; - int64_t ix; - int64_t i; double di; double S; double v; @@ -50,16 +66,12 @@ double stdlib_strided_dvarianceyc( const int64_t N, const double correction, con if ( N <= 0 || n <= 0.0 ) { return 0.0 / 0.0; // NaN } - if ( N == 1 || stride == 0 ) { + if ( N == 1 || strideX == 0 ) { return 0.0; } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } + ix = offsetX; sum = X[ ix ]; - ix += stride; + ix += strideX; S = 0.0; for ( i = 2; i <= N; i++ ) { di = (double)i; @@ -67,7 +79,7 @@ double stdlib_strided_dvarianceyc( const int64_t N, const double correction, con sum += v; d = (di*v) - sum; S += (1.0/(di*(di-1.0))) * d * d; - ix += stride; + ix += strideX; } return S / n; } diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.js index 142b3cbfc1ec..8d17ca5d2e75 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.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 dvarianceyc = require( './../lib/dvarianceyc.js' ); @@ -121,7 +120,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -136,15 +134,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, 2 ); + v = dvarianceyc( 4, 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; @@ -159,8 +155,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, -2 ); + v = dvarianceyc( 4, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -181,7 +176,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -197,9 +191,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 = dvarianceyc( N, 1, x1, 2 ); + v = dvarianceyc( 4, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.native.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.native.js index 25072750c664..596300d4e4cb 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.dvarianceyc.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' ); @@ -130,7 +129,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -145,15 +143,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, 2 ); + v = dvarianceyc( 4, 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; @@ -168,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, -2 ); + v = dvarianceyc( 4, 1, x, -2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -190,7 +185,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -206,9 +200,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 = dvarianceyc( N, 1, x1, 2 ); + v = dvarianceyc( 4, 1, x1, 2 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.ndarray.js index b6de2c690f6c..1e59205d3589 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/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 dvarianceyc = require( './../lib/ndarray.js' ); @@ -121,7 +120,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -136,15 +134,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, 2, 0 ); + v = dvarianceyc( 4, 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; @@ -159,8 +155,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, -2, 6 ); + v = dvarianceyc( 4, 1, x, -2, 6 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -179,7 +174,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -193,9 +187,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, 2, 1 ); + v = dvarianceyc( 4, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.ndarray.native.js index 612cc6f84168..b807dff5f972 100644 --- a/lib/node_modules/@stdlib/stats/base/dvarianceyc/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dvarianceyc/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' ); @@ -130,7 +129,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -145,15 +143,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, 2, 0 ); + v = dvarianceyc( 4, 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; @@ -168,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, -2, 6 ); + v = dvarianceyc( 4, 1, x, -2, 6 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end(); @@ -188,7 +183,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -202,9 +196,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dvarianceyc( N, 1, x, 2, 1 ); + v = dvarianceyc( 4, 1, x, 2, 1 ); t.strictEqual( v, 6.25, 'returns expected value' ); t.end();