Skip to content

Commit 70515e2

Browse files
chore: clean up
1 parent 1f14d89 commit 70515e2

File tree

21 files changed

+445
-121
lines changed

21 files changed

+445
-121
lines changed

lib/node_modules/@stdlib/stats/base/dnanstdev/README.md

Lines changed: 127 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,16 @@ The function has the following parameters:
116116
- **N**: number of indexed elements.
117117
- **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).
118118
- **x**: input [`Float64Array`][@stdlib/array/float64].
119-
- **stride**: index increment for `x`.
119+
- **strideX**: stride length for `x`.
120120

121-
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`,
121+
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`,
122122

123123
```javascript
124124
var Float64Array = require( '@stdlib/array/float64' );
125-
var floor = require( '@stdlib/math/base/special/floor' );
126125

127126
var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
128-
var N = floor( x.length / 2 );
129127

130-
var v = dnanstdev( N, 1, x, 2 );
128+
var v = dnanstdev( 4, 1, x, 2 );
131129
// returns 2.5
132130
```
133131

@@ -142,13 +140,11 @@ var floor = require( '@stdlib/math/base/special/floor' );
142140
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
143141
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
144142

145-
var N = floor( x0.length / 2 );
146-
147-
var v = dnanstdev( N, 1, x1, 2 );
143+
var v = dnanstdev( 4, 1, x1, 2 );
148144
// returns 2.5
149145
```
150146

151-
#### dnanstdev.ndarray( N, correction, x, stride, offset )
147+
#### dnanstdev.ndarray( N, correction, x, strideX, offsetX )
152148

153149
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array ignoring `NaN` values and using alternative indexing semantics.
154150

@@ -163,18 +159,16 @@ var v = dnanstdev.ndarray( x.length, 1, x, 1, 0 );
163159

164160
The function has the following additional parameters:
165161

166-
- **offset**: starting index for `x`.
162+
- **offsetX**: starting index for `x`.
167163

168-
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
164+
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
169165

170166
```javascript
171167
var Float64Array = require( '@stdlib/array/float64' );
172-
var floor = require( '@stdlib/math/base/special/floor' );
173168

174169
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
175-
var N = floor( x.length / 2 );
176170

177-
var v = dnanstdev.ndarray( N, 1, x, 2, 1 );
171+
var v = dnanstdev.ndarray( 4, 1, x, 2, 1 );
178172
// returns 2.5
179173
```
180174

@@ -222,6 +216,125 @@ console.log( v );
222216

223217
<!-- /.examples -->
224218

219+
<!-- C interface documentation. -->
220+
221+
* * *
222+
223+
<section class="c">
224+
225+
## C APIs
226+
227+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
228+
229+
<section class="intro">
230+
231+
</section>
232+
233+
<!-- /.intro -->
234+
235+
<!-- C usage documentation. -->
236+
237+
<section class="usage">
238+
239+
### Usage
240+
241+
```c
242+
#include "stdlib/stats/base/dnanstdev.h"
243+
```
244+
245+
#### stdlib_strided_dnanstdev( N, \*X, strideX )
246+
247+
Computes the standard deviation of a double-precision floating-point strided array ignoring `NaN` values.
248+
249+
```c
250+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
251+
252+
double v = stdlib_strided_dnanstdev( 6, 1.0, x, 2 );
253+
// returns 2.0736
254+
```
255+
256+
The function accepts the following arguments:
257+
258+
- **N**: `[in] CBLAS_INT` number of indexed elements.
259+
- **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).
260+
- **X**: `[in] double*` input array.
261+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
262+
263+
```c
264+
double stdlib_strided_dnanstdev( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
265+
```
266+
267+
#### stdlib_strided_dnanstdev_ndarray( N, \*X, strideX, offsetX )
268+
269+
Computes the standard deviation of a double-precision floating-point strided array ignoring `NaN` values and using alternative indexing semantics.
270+
271+
```c
272+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
273+
274+
double v = stdlib_strided_dnanstdev_ndarray( 6, 1.0, x, 2, 1 );
275+
// returns 2.0736
276+
```
277+
278+
The function accepts the following arguments:
279+
280+
- **N**: `[in] CBLAS_INT` number of indexed elements.
281+
- **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).
282+
- **X**: `[in] double*` input array.
283+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
284+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
285+
286+
```c
287+
double stdlib_strided_dnanstdev_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
288+
```
289+
290+
</section>
291+
292+
<!-- /.usage -->
293+
294+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
295+
296+
<section class="notes">
297+
298+
</section>
299+
300+
<!-- /.notes -->
301+
302+
<!-- C API usage examples. -->
303+
304+
<section class="examples">
305+
306+
### Examples
307+
308+
```c
309+
#include "stdlib/stats/base/dnanmeanwd.h"
310+
#include <stdio.h>
311+
312+
int main( void ) {
313+
// Create a strided array:
314+
const double x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
315+
316+
// Specify the number of elements:
317+
const int N = 6;
318+
319+
// Specify the stride length:
320+
const int strideX = 2;
321+
322+
// Compute the arithmetic mean:
323+
double v = stdlib_strided_dnanmeanwd( N, x, strideX );
324+
325+
// Print the result:
326+
printf( "mean: %lf\n", v );
327+
}
328+
```
329+
330+
</section>
331+
332+
<!-- /.examples -->
333+
334+
</section>
335+
336+
<!-- /.c -->
337+
225338
<section class="references">
226339
227340
</section>

lib/node_modules/@stdlib/stats/base/dnanstdev/benchmark/benchmark.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,30 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2527
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2628
var pow = require( '@stdlib/math/base/special/pow' );
27-
var Float64Array = require( '@stdlib/array/float64' );
2829
var pkg = require( './../package.json' ).name;
2930
var dnanstdev = require( './../lib/dnanstdev.js' );
3031

3132

3233
// FUNCTIONS //
3334

35+
/**
36+
* Returns a random value or `NaN`.
37+
*
38+
* @private
39+
* @returns {number} random number or `NaN`
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.2 ) ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
3448
/**
3549
* Creates a benchmark function.
3650
*
@@ -39,17 +53,7 @@ var dnanstdev = require( './../lib/dnanstdev.js' );
3953
* @returns {Function} benchmark function
4054
*/
4155
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float64Array( len );
46-
for ( i = 0; i < x.length; i++ ) {
47-
if ( randu() < 0.2 ) {
48-
x[ i ] = NaN;
49-
} else {
50-
x[ i ] = ( randu()*20.0 ) - 10.0;
51-
}
52-
}
56+
var x = filledarrayBy( len, 'float64', rand );
5357
return benchmark;
5458

5559
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/dnanstdev/benchmark/benchmark.native.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
26+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
27+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2628
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2729
var pow = require( '@stdlib/math/base/special/pow' );
28-
var Float64Array = require( '@stdlib/array/float64' );
2930
var tryRequire = require( '@stdlib/utils/try-require' );
3031
var pkg = require( './../package.json' ).name;
3132

@@ -40,6 +41,19 @@ var opts = {
4041

4142
// FUNCTIONS //
4243

44+
/**
45+
* Returns a random value or `NaN`.
46+
*
47+
* @private
48+
* @returns {number} random number or `NaN`
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.2 ) ) {
52+
return NaN;
53+
}
54+
return uniform( -10.0, 10.0 );
55+
}
56+
4357
/**
4458
* Creates a benchmark function.
4559
*
@@ -48,17 +62,7 @@ var opts = {
4862
* @returns {Function} benchmark function
4963
*/
5064
function createBenchmark( len ) {
51-
var x;
52-
var i;
53-
54-
x = new Float64Array( len );
55-
for ( i = 0; i < x.length; i++ ) {
56-
if ( randu() < 0.2 ) {
57-
x[ i ] = NaN;
58-
} else {
59-
x[ i ] = ( randu()*20.0 ) - 10.0;
60-
}
61-
}
65+
var x = filledarrayBy( len, 'float64', rand );
6266
return benchmark;
6367

6468
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/dnanstdev/benchmark/benchmark.ndarray.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,30 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2527
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2628
var pow = require( '@stdlib/math/base/special/pow' );
27-
var Float64Array = require( '@stdlib/array/float64' );
2829
var pkg = require( './../package.json' ).name;
2930
var dnanstdev = require( './../lib/ndarray.js' );
3031

3132

3233
// FUNCTIONS //
3334

35+
/**
36+
* Returns a random value or `NaN`.
37+
*
38+
* @private
39+
* @returns {number} random number or `NaN`
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.2 ) ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
3448
/**
3549
* Creates a benchmark function.
3650
*
@@ -39,17 +53,7 @@ var dnanstdev = require( './../lib/ndarray.js' );
3953
* @returns {Function} benchmark function
4054
*/
4155
function createBenchmark( len ) {
42-
var x;
43-
var i;
44-
45-
x = new Float64Array( len );
46-
for ( i = 0; i < x.length; i++ ) {
47-
if ( randu() < 0.2 ) {
48-
x[ i ] = NaN;
49-
} else {
50-
x[ i ] = ( randu()*20.0 ) - 10.0;
51-
}
52-
}
56+
var x = filledarrayBy( len, 'float64', rand );
5357
return benchmark;
5458

5559
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/dnanstdev/benchmark/benchmark.ndarray.native.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
26+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
27+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2628
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2729
var pow = require( '@stdlib/math/base/special/pow' );
28-
var Float64Array = require( '@stdlib/array/float64' );
2930
var tryRequire = require( '@stdlib/utils/try-require' );
3031
var pkg = require( './../package.json' ).name;
3132

@@ -40,6 +41,19 @@ var opts = {
4041

4142
// FUNCTIONS //
4243

44+
/**
45+
* Returns a random value or `NaN`.
46+
*
47+
* @private
48+
* @returns {number} random number or `NaN`
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.2 ) ) {
52+
return NaN;
53+
}
54+
return uniform( -10.0, 10.0 );
55+
}
56+
4357
/**
4458
* Creates a benchmark function.
4559
*
@@ -48,17 +62,7 @@ var opts = {
4862
* @returns {Function} benchmark function
4963
*/
5064
function createBenchmark( len ) {
51-
var x;
52-
var i;
53-
54-
x = new Float64Array( len );
55-
for ( i = 0; i < x.length; i++ ) {
56-
if ( randu() < 0.2 ) {
57-
x[ i ] = NaN;
58-
} else {
59-
x[ i ] = ( randu()*20.0 ) - 10.0;
60-
}
61-
}
65+
var x = filledarrayBy( len, 'float64', rand );
6266
return benchmark;
6367

6468
function benchmark( b ) {

0 commit comments

Comments
 (0)