diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/README.md b/lib/node_modules/@stdlib/stats/base/dstdevyc/README.md index 768af0905646..6b927257be01 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/README.md +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/README.md @@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note, var dstdevyc = require( '@stdlib/stats/base/dstdevyc' ); ``` -#### dstdevyc( N, correction, x, stride ) +#### dstdevyc( N, correction, x, strideX ) Computes the [standard deviation][standard-deviation] 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 [standard deviation][standard-deviation] of a double-precision floa var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = dstdevyc( N, 1, x, 1 ); +var v = dstdevyc( x.length, 1.0, x, 1 ); // returns ~2.0817 ``` @@ -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 [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). - **x**: input [`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 [standard deviation][standard-deviation] of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`, ```javascript var 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 = dstdevyc( N, 1, x, 2 ); +var v = dstdevyc( 4, 1.0, x, 2 ); // returns 2.5 ``` @@ -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 = dstdevyc( N, 1, x1, 2 ); +var v = dstdevyc( 4, 1.0, x1, 2 ); // returns 2.5 ``` -#### dstdevyc.ndarray( N, correction, x, stride, offset ) +#### dstdevyc.ndarray( N, correction, x, strideX, offsetX ) Computes the [standard deviation][standard-deviation] 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 [standard deviation][standard-deviation] of a double-precision floa var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -var N = x.length; -var v = dstdevyc.ndarray( N, 1, x, 1, 0 ); +var v = dstdevyc.ndarray( x.length, 1.0, x, 1, 0 ); // returns ~2.0817 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [standard deviation][standard-deviation] for every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [standard deviation][standard-deviation] for every other element in `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 = dstdevyc.ndarray( N, 1, x, 2, 1 ); +var v = dstdevyc.ndarray( 4, 1.0, x, 2, 1 ); // returns 2.5 ``` @@ -202,21 +193,15 @@ var v = dstdevyc.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 dstdevyc = require( '@stdlib/stats/base/dstdevyc' ); -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 = dstdevyc( x.length, 1, x, 1 ); +var v = dstdevyc( x.length, 1.0, x, 1 ); console.log( v ); ``` @@ -224,6 +209,125 @@ console.log( v ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dstdevyc.h" +``` + +#### stdlib_strided_dstdevyc( N, correction, \*X, strideX ) + +Computes the [standard deviation][standard-deviation] 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_dstdevyc( 3, 1.0, x, 1 ); +// returns ~2.0817 +``` + +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 [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). +- **X**: `[in] double*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. + +```c +double stdlib_strided_dstdevyc( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_dstdevyc_ndarray( N, correction, \*X, strideX, offsetX ) + +Computes the [standard deviation][standard-deviation] 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_dstdevyc_ndarray( 3, 1.0, x, 1, 0 ); +// returns ~2.0817 +``` + +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 [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). +- **X**: `[in] double*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. + +```c +double stdlib_strided_dstdevyc_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/dstdevyc.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_dstdevyc( N, 1.0, x, strideX ); + + // Print the result: + printf( "sample standard deviation: %lf\n", v ); +} +``` + +
+ + + +
+ + + * * *
diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.js index c7ab1cac4426..ee12c4736465 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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 dstdevyc = require( './../lib/dstdevyc.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -39,13 +45,7 @@ var dstdevyc = require( './../lib/dstdevyc.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 ) { @@ -54,7 +54,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.native.js index b9d6ccef2cf7..3fa5f9ea3860 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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 dstdevyc = tryRequire( resolve( __dirname, './../lib/dstdevyc.native.js' ) ) var opts = { 'skip': ( dstdevyc 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 ) { @@ -63,7 +59,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.ndarray.js index 7dfbb13b5579..4f8c661eb5ce 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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 dstdevyc = require( './../lib/ndarray.js' ); +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + // FUNCTIONS // /** @@ -39,13 +45,7 @@ var dstdevyc = 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 ) { @@ -54,7 +54,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.ndarray.native.js index e820e8a25e9e..e95104f7f2e9 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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 dstdevyc = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dstdevyc 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 ) { @@ -63,7 +59,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); if ( isnan( v ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/c/benchmark.length.c index 1ee95938acd6..6552916b0bf8 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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_dstdevyc( 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_dstdevyc_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/dstdevyc/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/repl.txt index d7dba08e1253..f96e88560206 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/repl.txt @@ -1,10 +1,10 @@ -{{alias}}( N, correction, x, stride ) +{{alias}}( N, correction, x, strideX ) Computes the standard deviation 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 ------- @@ -43,25 +43,22 @@ -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); - > {{alias}}( x.length, 1, x, 1 ) + > {{alias}}( x.length, 1.0, x, 1 ) ~2.0817 - // 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.0, x, 2 ) ~2.0817 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, 1, x1, stride ) + > {{alias}}( 3, 1.0, x1, 2 ) ~2.0817 -{{alias}}.ndarray( N, correction, x, stride, offset ) + +{{alias}}.ndarray( N, correction, x, strideX, offsetX ) Computes the standard deviation 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 @@ -105,13 +102,12 @@ -------- // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); - > {{alias}}.ndarray( x.length, 1, x, 1, 0 ) + > {{alias}}.ndarray( x.length, 1.0, x, 1, 0 ) ~2.0817 // 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.0, x, 2, 1 ) ~2.0817 See Also diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/index.d.ts index be789ff684cf..6df16ce43a7d 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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 standard deviation * * @example @@ -36,10 +36,10 @@ interface Routine { * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * - * var v = dstdevyc( x.length, 1, x, 1 ); + * var v = dstdevyc( x.length, 1.0, x, 1 ); * // returns ~2.0817 */ - ( N: number, correction: number, x: Float64Array, stride: number ): number; + ( N: number, correction: number, x: Float64Array, strideX: number ): number; /** * Computes the standard deviation 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 standard deviation * * @example @@ -56,10 +56,10 @@ interface Routine { * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * - * var v = dstdevyc.ndarray( x.length, 1, x, 1, 0 ); + * var v = dstdevyc.ndarray( x.length, 1.0, x, 1, 0 ); * // returns ~2.0817 */ - 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 standard deviation * * @example @@ -76,7 +76,7 @@ interface Routine { * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * -* var v = dstdevyc( x.length, 1, x, 1 ); +* var v = dstdevyc( x.length, 1.0, x, 1 ); * // returns ~2.0817 * * @example @@ -84,7 +84,7 @@ interface Routine { * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * -* var v = dstdevyc.ndarray( x.length, 1, x, 1, 0 ); +* var v = dstdevyc.ndarray( x.length, 1.0, x, 1, 0 ); * // returns ~2.0817 */ declare var dstdevyc: Routine; diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/test.ts index bdb011468b50..781bc13d5c1d 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/docs/types/test.ts @@ -25,21 +25,21 @@ import dstdevyc = require( './index' ); { const x = new Float64Array( 10 ); - dstdevyc( x.length, 1, x, 1 ); // $ExpectType number + dstdevyc( x.length, 1.0, x, 1 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... { const x = new Float64Array( 10 ); - dstdevyc( '10', 1, x, 1 ); // $ExpectError - dstdevyc( true, 1, x, 1 ); // $ExpectError - dstdevyc( false, 1, x, 1 ); // $ExpectError - dstdevyc( null, 1, x, 1 ); // $ExpectError - dstdevyc( undefined, 1, x, 1 ); // $ExpectError - dstdevyc( [], 1, x, 1 ); // $ExpectError - dstdevyc( {}, 1, x, 1 ); // $ExpectError - dstdevyc( ( x: number ): number => x, 1, x, 1 ); // $ExpectError + dstdevyc( '10', 1.0, x, 1 ); // $ExpectError + dstdevyc( true, 1.0, x, 1 ); // $ExpectError + dstdevyc( false, 1.0, x, 1 ); // $ExpectError + dstdevyc( null, 1.0, x, 1 ); // $ExpectError + dstdevyc( undefined, 1.0, x, 1 ); // $ExpectError + dstdevyc( [], 1.0, x, 1 ); // $ExpectError + dstdevyc( {}, 1.0, x, 1 ); // $ExpectError + dstdevyc( ( x: number ): number => x, 1.0, x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -60,29 +60,29 @@ import dstdevyc = require( './index' ); { const x = new Float64Array( 10 ); - dstdevyc( x.length, 1, 10, 1 ); // $ExpectError - dstdevyc( x.length, 1, '10', 1 ); // $ExpectError - dstdevyc( x.length, 1, true, 1 ); // $ExpectError - dstdevyc( x.length, 1, false, 1 ); // $ExpectError - dstdevyc( x.length, 1, null, 1 ); // $ExpectError - dstdevyc( x.length, 1, undefined, 1 ); // $ExpectError - dstdevyc( x.length, 1, [], 1 ); // $ExpectError - dstdevyc( x.length, 1, {}, 1 ); // $ExpectError - dstdevyc( x.length, 1, ( x: number ): number => x, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, 10, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, '10', 1 ); // $ExpectError + dstdevyc( x.length, 1.0, true, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, false, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, null, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, undefined, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, [], 1 ); // $ExpectError + dstdevyc( x.length, 1.0, {}, 1 ); // $ExpectError + dstdevyc( x.length, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { const x = new Float64Array( 10 ); - dstdevyc( x.length, 1, x, '10' ); // $ExpectError - dstdevyc( x.length, 1, x, true ); // $ExpectError - dstdevyc( x.length, 1, x, false ); // $ExpectError - dstdevyc( x.length, 1, x, null ); // $ExpectError - dstdevyc( x.length, 1, x, undefined ); // $ExpectError - dstdevyc( x.length, 1, x, [] ); // $ExpectError - dstdevyc( x.length, 1, x, {} ); // $ExpectError - dstdevyc( x.length, 1, x, ( x: number ): number => x ); // $ExpectError + dstdevyc( x.length, 1.0, x, '10' ); // $ExpectError + dstdevyc( x.length, 1.0, x, true ); // $ExpectError + dstdevyc( x.length, 1.0, x, false ); // $ExpectError + dstdevyc( x.length, 1.0, x, null ); // $ExpectError + dstdevyc( x.length, 1.0, x, undefined ); // $ExpectError + dstdevyc( x.length, 1.0, x, [] ); // $ExpectError + dstdevyc( x.length, 1.0, x, {} ); // $ExpectError + dstdevyc( x.length, 1.0, x, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -91,30 +91,30 @@ import dstdevyc = require( './index' ); dstdevyc(); // $ExpectError dstdevyc( x.length ); // $ExpectError - dstdevyc( x.length, 1 ); // $ExpectError - dstdevyc( x.length, 1, x ); // $ExpectError - dstdevyc( x.length, 1, x, 1, 10 ); // $ExpectError + dstdevyc( x.length, 1.0 ); // $ExpectError + dstdevyc( x.length, 1.0, x ); // $ExpectError + dstdevyc( x.length, 1.0, x, 1, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a number... { const x = new Float64Array( 10 ); - dstdevyc.ndarray( x.length, 1, x, 1, 0 ); // $ExpectType number + dstdevyc.ndarray( x.length, 1.0, x, 1, 0 ); // $ExpectType number } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... { const x = new Float64Array( 10 ); - dstdevyc.ndarray( '10', 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( true, 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( false, 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( null, 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( undefined, 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( [], 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( {}, 1, x, 1, 0 ); // $ExpectError - dstdevyc.ndarray( ( x: number ): number => x, 1, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( '10', 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( true, 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( false, 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( null, 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( undefined, 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( [], 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( {}, 1.0, x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( ( x: number ): number => x, 1.0, x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... @@ -135,43 +135,43 @@ import dstdevyc = require( './index' ); { const x = new Float64Array( 10 ); - dstdevyc.ndarray( x.length, 1, 10, 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, '10', 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, true, 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, false, 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, null, 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, undefined, 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, [], 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, {}, 1, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, ( x: number ): number => x, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, 10, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, '10', 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, true, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, false, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, null, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, undefined, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, [], 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, {}, 1, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... { const x = new Float64Array( 10 ); - dstdevyc.ndarray( x.length, 1, x, '10', 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, true, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, false, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, null, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, undefined, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, [], 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, {}, 0 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, ( x: number ): number => x, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, '10', 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, true, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, false, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, null, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, undefined, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, [], 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, {}, 0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... { const x = new Float64Array( 10 ); - dstdevyc.ndarray( x.length, 1, x, 1, '10' ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, true ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, false ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, null ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, undefined ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, [] ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, {} ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, ( x: number ): number => x ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, '10' ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, true ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, false ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, null ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, undefined ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, [] ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, {} ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -180,8 +180,8 @@ import dstdevyc = require( './index' ); dstdevyc.ndarray(); // $ExpectError dstdevyc.ndarray( x.length ); // $ExpectError - dstdevyc.ndarray( x.length, 1 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1 ); // $ExpectError - dstdevyc.ndarray( x.length, 1, x, 1, 0, 10 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1 ); // $ExpectError + dstdevyc.ndarray( x.length, 1.0, x, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/c/example.c index cccb616d0749..38867e242dac 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/dstdevyc.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 standard deviation: - double v = stdlib_strided_dstdevyc( N, 1, x, stride ); + double v = stdlib_strided_dstdevyc( N, 1.0, x, strideX ); // Print the result: printf( "sample standard deviation: %lf\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/index.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/index.js index 8b9a1fb42fcc..b097cd431352 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/examples/index.js @@ -18,19 +18,13 @@ '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 dstdevyc = 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 = dstdevyc( x.length, 1, x, 1 ); +var v = dstdevyc( x.length, 1.0, x, 1 ); console.log( v ); diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/include/stdlib/stats/base/dstdevyc.h b/lib/node_modules/@stdlib/stats/base/dstdevyc/include/stdlib/stats/base/dstdevyc.h index c2c7c904c7bd..4aff22a2f126 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/include/stdlib/stats/base/dstdevyc.h +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/include/stdlib/stats/base/dstdevyc.h @@ -19,7 +19,7 @@ #ifndef STDLIB_STATS_BASE_DSTDEVYC_H #define STDLIB_STATS_BASE_DSTDEVYC_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 standard deviation of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. */ -double stdlib_strided_dstdevyc( const int64_t N, const double correction, const double *X, const int64_t stride ); +double API_SUFFIX(stdlib_strided_dstdevyc)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX ); + +/** +* Computes the standard deviation 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_dstdevyc_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/dstdevyc/lib/dstdevyc.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.js index 2f73390a3c99..3f947f520f86 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.js @@ -20,8 +20,8 @@ // MODULES // -var dvarianceyc = require( '@stdlib/stats/base/dvarianceyc' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); // MAIN // @@ -36,20 +36,19 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * @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} standard deviation * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = dstdevyc( N, 1, x, 1 ); +* var v = dstdevyc( x.length, 1.0, x, 1 ); * // returns ~2.0817 */ -function dstdevyc( N, correction, x, stride ) { - return sqrt( dvarianceyc( N, correction, x, stride ) ); +function dstdevyc( N, correction, x, strideX ) { + return ndarray( N, correction, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.native.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.native.js index 1412a9fe066b..922cfa5ad004 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.native.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/dstdevyc.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} standard deviation * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = dstdevyc( N, 1, x, 1 ); +* var v = dstdevyc( x.length, 1.0, x, 1 ); * // returns ~2.0817 */ -function dstdevyc( N, correction, x, stride ) { - return addon( N, correction, x, stride ); +function dstdevyc( N, correction, x, strideX ) { + return addon( N, correction, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/index.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/index.js index b639bfc51b40..dbba359a4626 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/index.js @@ -28,20 +28,17 @@ * var dstdevyc = require( '@stdlib/stats/base/dstdevyc' ); * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); -* var N = x.length; * -* var v = dstdevyc( N, 1, x, 1 ); +* var v = dstdevyc( x.length, 1.0, x, 1 ); * // returns ~2.0817 * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dstdevyc = require( '@stdlib/stats/base/dstdevyc' ); * * 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 = dstdevyc.ndarray( N, 1, x, 2, 1 ); +* var v = dstdevyc.ndarray( 4, 1.0, x, 2, 1 ); * // returns 2.5 */ diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.js index f00395d9c3cb..19f36e809f05 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.js @@ -36,22 +36,20 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * @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} standard deviation * * @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 = dstdevyc( N, 1, x, 2, 1 ); +* var v = dstdevyc( 4, 1.0, x, 2, 1 ); * // returns 2.5 */ -function dstdevyc( N, correction, x, stride, offset ) { - return sqrt( dvarianceyc( N, correction, x, stride, offset ) ); +function dstdevyc( N, correction, x, strideX, offsetX ) { + return sqrt( dvarianceyc( N, correction, x, strideX, offsetX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.native.js index f289426d1e75..ff494e65917d 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); -var addon = require( './dstdevyc.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -32,27 +31,20 @@ var addon = require( './dstdevyc.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} standard deviation * * @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 = dstdevyc( N, 1, x, 2, 1 ); +* var v = dstdevyc( 4, 1.0, x, 2, 1 ); * // returns 2.5 */ -function dstdevyc( 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 dstdevyc( N, correction, x, strideX, offsetX ) { + return addon.ndarray( N, correction, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/manifest.json b/lib/node_modules/@stdlib/stats/base/dstdevyc/manifest.json index 11ff85b680fb..db81f65afb3a 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,17 +28,19 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ - "./src/dstdevyc.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/sqrt", "@stdlib/stats/base/dvarianceyc", "@stdlib/napi/export", "@stdlib/napi/argv", @@ -49,33 +52,55 @@ }, { "task": "benchmark", + "wasm": false, "src": [ - "./src/dstdevyc.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/sqrt", "@stdlib/stats/base/dvarianceyc" ] }, { "task": "examples", + "wasm": false, "src": [ - "./src/dstdevyc.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/sqrt", + "@stdlib/stats/base/dvarianceyc" + ] + }, + { + "task": "", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" ], + "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/math/base/special/sqrt", "@stdlib/stats/base/dvarianceyc" ] } diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/src/addon.c b/lib/node_modules/@stdlib/stats/base/dstdevyc/src/addon.c index b86395f29211..b3fb8a63b5e5 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/src/addon.c @@ -17,6 +17,7 @@ */ #include "stdlib/stats/base/dstdevyc.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_dstdevyc( 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_dstdevyc)( 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_dstdevyc_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/dstdevyc/src/dstdevyc.c b/lib/node_modules/@stdlib/stats/base/dstdevyc/src/dstdevyc.c deleted file mode 100644 index 6e6535361ee7..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/src/dstdevyc.c +++ /dev/null @@ -1,39 +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/dstdevyc.h" -#include "stdlib/stats/base/dvarianceyc.h" -#include -#include - -/** -* Computes the standard deviation of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. -* -* ## References -* -* - Youngs, Edward A., and Elliot M. Cramer. 1971. "Some Results Relevant to Choice of Sum and Sum-of-Product Algorithms." _Technometrics_ 13 (3): 657–65. doi:[10.1080/00401706.1971.10488826](https://doi.org/10.1080/00401706.1971.10488826). -* -* @param 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_dstdevyc( const int64_t N, const double correction, const double *X, const int64_t stride ) { - return sqrt( stdlib_strided_dvarianceyc( N, correction, X, stride ) ); -} diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/src/main.c b/lib/node_modules/@stdlib/stats/base/dstdevyc/src/main.c new file mode 100644 index 000000000000..72ea3b7a1ef8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/src/main.c @@ -0,0 +1,55 @@ +/** +* @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/dstdevyc.h" +#include "stdlib/stats/base/dvarianceyc.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/math/base/special/sqrt.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Computes the standard deviation of a double-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer. +* +* ## References +* +* - Youngs, Edward A., and Elliot M. Cramer. 1971. "Some Results Relevant to Choice of Sum and Sum-of-Product Algorithms." _Technometrics_ 13 (3): 657–65. doi:[10.1080/00401706.1971.10488826](https://doi.org/10.1080/00401706.1971.10488826). +* +* @param 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_dstdevyc)( 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_dstdevyc_ndarray)( N, correction, X, strideX, ox ); +} + +/** +* Computes the standard deviation 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_dstdevyc_ndarray)( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + return stdlib_base_sqrt( API_SUFFIX(stdlib_strided_dvarianceyc_ndarray)( N, correction, X, strideX, offsetX ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.js index e3d34d3a7825..477805fd2f06 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -46,15 +45,15 @@ tape( 'the function calculates the population standard deviation of a strided ar var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 0, x, 1 ); + v = dstdevyc( x.length, 0.0, x, 1 ); t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 0, x, 1 ); + v = dstdevyc( x.length, 0.0, x, 1 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 0, x, 1 ); + v = dstdevyc( x.length, 0.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -65,15 +64,15 @@ tape( 'the function calculates the sample standard deviation of a strided array' var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -85,10 +84,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 0, 1, x, 1 ); + v = dstdevyc( 0, 1.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - v = dstdevyc( -1, 1, x, 1 ); + v = dstdevyc( -1, 1.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -100,7 +99,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 1, 0, x, 1 ); + v = dstdevyc( 1, 0.0, x, 1 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -122,7 +121,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -137,15 +135,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, 2 ); + v = dstdevyc( 4, 1.0, x, 2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -160,8 +156,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, -2 ); + v = dstdevyc( 4, 1.0, x, -2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -173,7 +168,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 0 ); + v = dstdevyc( x.length, 1.0, x, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -182,7 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float64Array([ @@ -198,9 +192,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dstdevyc( N, 1, x1, 2 ); + v = dstdevyc( 4, 1.0, x1, 2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.native.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.native.js index 525500025840..81ae8890577e 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.native.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.dstdevyc.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -55,15 +54,15 @@ tape( 'the function calculates the population standard deviation of a strided ar var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 0, x, 1 ); + v = dstdevyc( x.length, 0.0, x, 1 ); t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 0, x, 1 ); + v = dstdevyc( x.length, 0.0, x, 1 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 0, x, 1 ); + v = dstdevyc( x.length, 0.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -74,15 +73,15 @@ tape( 'the function calculates the sample standard deviation of a strided array' var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 1, x, 1 ); + v = dstdevyc( x.length, 1.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -94,10 +93,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 0, 1, x, 1 ); + v = dstdevyc( 0, 1.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - v = dstdevyc( -1, 1, x, 1 ); + v = dstdevyc( -1, 1.0, x, 1 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -109,7 +108,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 1, 0, x, 1 ); + v = dstdevyc( 1, 0.0, x, 1 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -131,7 +130,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; @@ -146,15 +144,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, 2 ); + v = dstdevyc( 4, 1.0, x, 2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -169,8 +165,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, -2 ); + v = dstdevyc( 4, 1.0, x, -2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -182,7 +177,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 0 ); + v = dstdevyc( x.length, 1.0, x, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -191,7 +186,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([ @@ -207,9 +201,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 = dstdevyc( N, 1, x1, 2 ); + v = dstdevyc( 4, 1.0, x1, 2 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.js index b3d64390e38a..3f290f7e06e0 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -46,15 +45,15 @@ tape( 'the function calculates the population standard deviation of a strided ar var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 0, x, 1, 0 ); + v = dstdevyc( x.length, 0.0, x, 1, 0 ); t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 0, x, 1, 0 ); + v = dstdevyc( x.length, 0.0, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 0, x, 1, 0 ); + v = dstdevyc( x.length, 0.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -65,15 +64,15 @@ tape( 'the function calculates the sample standard deviation of a strided array' var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -85,10 +84,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 0, 1, x, 1, 0 ); + v = dstdevyc( 0, 1.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - v = dstdevyc( -1, 1, x, 1, 0 ); + v = dstdevyc( -1, 1.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -100,7 +99,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 1, 0, x, 1, 0 ); + v = dstdevyc( 1, 0.0, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -122,7 +121,6 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -137,15 +135,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, 2, 0 ); + v = dstdevyc( 4, 1.0, x, 2, 0 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -160,8 +156,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, -2, 6 ); + v = dstdevyc( 4, 1.0, x, -2, 6 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -173,14 +168,13 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 0, 0 ); + v = dstdevyc( x.length, 1.0, x, 0, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -194,9 +188,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, 2, 1 ); + v = dstdevyc( 4, 1.0, x, 2, 1 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.native.js index e75c9ef0079a..a4e744221b92 100644 --- a/lib/node_modules/@stdlib/stats/base/dstdevyc/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dstdevyc/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 sqrt = require( '@stdlib/math/base/special/sqrt' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -55,15 +54,15 @@ tape( 'the function calculates the population standard deviation of a strided ar var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 0, x, 1, 0 ); + v = dstdevyc( x.length, 0.0, x, 1, 0 ); t.strictEqual( v, sqrt( 53.5/x.length ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 0, x, 1, 0 ); + v = dstdevyc( x.length, 0.0, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 0, x, 1, 0 ); + v = dstdevyc( x.length, 0.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -74,15 +73,15 @@ tape( 'the function calculates the sample standard deviation of a strided array' var v; x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); t.strictEqual( v, sqrt( 53.5/(x.length-1) ), 'returns expected value' ); x = new Float64Array( [ -4.0, -4.0 ] ); - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); x = new Float64Array( [ NaN, 4.0 ] ); - v = dstdevyc( x.length, 1, x, 1, 0 ); + v = dstdevyc( x.length, 1.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -94,10 +93,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 0, 1, x, 1, 0 ); + v = dstdevyc( 0, 1.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); - v = dstdevyc( -1, 1, x, 1, 0 ); + v = dstdevyc( -1, 1.0, x, 1, 0 ); t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); @@ -109,7 +108,7 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( 1, 0, x, 1, 0 ); + v = dstdevyc( 1, 0.0, x, 1, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); @@ -131,7 +130,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; @@ -146,15 +144,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, 2, 0 ); + v = dstdevyc( 4, 1.0, x, 2, 0 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -169,8 +165,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, -2, 6 ); + v = dstdevyc( 4, 1.0, x, -2, 6 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end(); @@ -182,14 +177,13 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0`', x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dstdevyc( x.length, 1, x, 0, 0 ); + v = dstdevyc( x.length, 1.0, x, 0, 0 ); t.strictEqual( v, 0.0, 'returns expected value' ); t.end(); }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -203,9 +197,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = floor( x.length / 2 ); - v = dstdevyc( N, 1, x, 2, 1 ); + v = dstdevyc( 4, 1.0, x, 2, 1 ); t.strictEqual( v, 2.5, 'returns expected value' ); t.end();