Skip to content

Commit 6d757bc

Browse files
chore: minor clean up
1 parent 3919f70 commit 6d757bc

File tree

14 files changed

+104
-56
lines changed

14 files changed

+104
-56
lines changed

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

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ The [arithmetic mean][arithmetic-mean] is defined as
5151
var dnanmeanpn = require( '@stdlib/stats/base/dnanmeanpn' );
5252
```
5353

54-
#### dnanmeanpn( N, x, stride )
54+
#### dnanmeanpn( N, x, strideX )
5555

5656
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array `x`, ignoring `NaN` values and using a two-pass error correction algorithm.
5757

5858
```javascript
5959
var Float64Array = require( '@stdlib/array/float64' );
6060

6161
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
62-
var N = x.length;
6362

64-
var v = dnanmeanpn( N, x, 1 );
63+
var v = dnanmeanpn( x.length, x, 1 );
6564
// returns ~0.3333
6665
```
6766

@@ -71,16 +70,14 @@ The function has the following parameters:
7170
- **x**: input [`Float64Array`][@stdlib/array/float64].
7271
- **stride**: index increment for `x`.
7372

74-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
73+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
7574

7675
```javascript
7776
var Float64Array = require( '@stdlib/array/float64' );
78-
var floor = require( '@stdlib/math/base/special/floor' );
7977

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

83-
var v = dnanmeanpn( N, x, 2 );
80+
var v = dnanmeanpn( 4, x, 2 );
8481
// returns 1.25
8582
```
8683

@@ -90,45 +87,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
9087

9188
```javascript
9289
var Float64Array = require( '@stdlib/array/float64' );
93-
var floor = require( '@stdlib/math/base/special/floor' );
9490

9591
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
9692
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9793

98-
var N = floor( x0.length / 2 );
99-
100-
var v = dnanmeanpn( N, x1, 2 );
94+
var v = dnanmeanpn( 4, x1, 2 );
10195
// returns 1.25
10296
```
10397

104-
#### dnanmeanpn.ndarray( N, x, stride, offset )
98+
#### dnanmeanpn.ndarray( N, x, strideX, offsetX )
10599

106100
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
107101

108102
```javascript
109103
var Float64Array = require( '@stdlib/array/float64' );
110104

111105
var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
112-
var N = x.length;
113106

114-
var v = dnanmeanpn.ndarray( N, x, 1, 0 );
107+
var v = dnanmeanpn.ndarray( x.length, x, 1, 0 );
115108
// returns ~0.33333
116109
```
117110

118111
The function has the following additional parameters:
119112

120-
- **offset**: starting index for `x`.
113+
- **offsetX**: starting index for `x`.
121114

122-
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 [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value
115+
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 [arithmetic mean][arithmetic-mean] for every other element in `x` starting from the second element
123116

124117
```javascript
125118
var Float64Array = require( '@stdlib/array/float64' );
126-
var floor = require( '@stdlib/math/base/special/floor' );
127119

128120
var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
129-
var N = floor( x.length / 2 );
130121

131-
var v = dnanmeanpn.ndarray( N, x, 2, 1 );
122+
var v = dnanmeanpn.ndarray( 4, x, 2, 1 );
132123
// returns 1.25
133124
```
134125

@@ -192,12 +183,12 @@ console.log( v );
192183

193184
#### stdlib_strided_dnanmeanpn( N, \*X, strideX )
194185

195-
Calculate the mean value of a double-precision floating-point strided array, ignoring `NaN` values.
186+
Computes arithmetic mean of a double-precision floating-point strided array `x`, ignoring `NaN` values and using a two-pass error correction algorithm.
196187

197188
```c
198189
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 };
199190

200-
double v = stdlib_strided_dnanmeanpn( 5, x, 2 );
191+
double v = stdlib_strided_dnanmeanpn( 6, x, 2 );
201192
// returns 1.25
202193
```
203194
@@ -211,14 +202,14 @@ The function accepts the following arguments:
211202
double stdlib_strided_dnanmeanpn( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
212203
```
213204

214-
#### stdlib_strided_dsmeanwd_ndarray( N, \*X, strideX, offsetX )
205+
#### stdlib_strided_dnanmeanpn_ndarray( N, \*X, strideX, offsetX )
215206

216-
Computes the mean value of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
207+
Computes the aithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
217208

218209
```c
219210
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 };
220211

221-
double v = stdlib_strided_dnanmeanpn( 5, x, 2, 0 );
212+
double v = stdlib_strided_dnanmeanpn( 6, x, 2, 0 );
222213
// returns 1.25
223214
```
224215

lib/node_modules/@stdlib/stats/base/dnanmeanpn/docs/repl.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
array, ignoring `NaN` values and using a two-pass error correction
55
algorithm.
66

7-
The `N` and `stride` parameters determine which elements in `x` are accessed
8-
at runtime.
7+
The `N` and stride parameters determine which elements in the strided array
8+
are accessed at runtime.
99

1010
Indexing is relative to the first index. To introduce an offset, use a typed
1111
array view.
@@ -23,7 +23,7 @@
2323
Input array.
2424

2525
strideX: integer
26-
Stride Length.
26+
Stride length.
2727

2828
Returns
2929
-------
@@ -37,16 +37,16 @@
3737
> {{alias}}( x.length, x, 1 )
3838
~0.3333
3939

40-
// Using `N` and `stride` parameters:
40+
// Using `N` and stride parameters:
4141
> x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN ] );
42-
> {{alias}}( 6, x, 2 )
43-
NaN
42+
> {{alias}}( 3, x, 2 )
43+
~0.3333
4444

4545
// Using view offsets:
4646
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] );
4747
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
48-
> {{alias}}( 6, x1, 2 )
49-
NaN
48+
> {{alias}}( 3, x1, 2 )
49+
~-0.3333
5050

5151

5252
{{alias}}.ndarray( N, x, strideX, offsetX )
@@ -67,7 +67,7 @@
6767
Input array.
6868

6969
strideX: integer
70-
Stride Length.
70+
Stride length.
7171

7272
offsetX: integer
7373
Starting index.
@@ -86,8 +86,8 @@
8686

8787
// Using offset parameter:
8888
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] );
89-
> {{alias}}.ndarray( 6, x, 2, 1 )
90-
NaN
89+
> {{alias}}.ndarray( 3, x, 2, 1 )
90+
~-0.3333
9191

9292
See Also
9393
--------

lib/node_modules/@stdlib/stats/base/dnanmeanpn/examples/index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,22 @@
1818

1919
'use strict';
2020

21-
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
21+
var randu = require( '@stdlib/random/base/randu' );
22+
var round = require( '@stdlib/math/base/special/round' );
23+
var Float64Array = require( '@stdlib/array/float64' );
2224
var dnanmeanpn = require( './../lib' );
2325

24-
var x = discreteUniform( 10, -50, 50, {
25-
'dtype': 'float32'
26-
});
26+
var x;
27+
var i;
28+
29+
x = new Float64Array( 10 );
30+
for ( i = 0; i < x.length; i++ ) {
31+
if ( randu() < 0.2 ) {
32+
x[ i ] = NaN;
33+
} else {
34+
x[ i ] = round( randu() * 10.0 );
35+
}
36+
}
2737
console.log( x );
2838

2939
var v = dnanmeanpn( x.length, x, 1 );

lib/node_modules/@stdlib/stats/base/dnanmeanpn/include/stdlib/stats/base/dnanmeanpn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
double API_SUFFIX(stdlib_strided_dnanmeanpn)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
3535

3636
/**
37-
* Computes the maximum absolute value of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics .
37+
* Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
3838
*/
3939
double API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
4040

lib/node_modules/@stdlib/stats/base/dnanmeanpn/lib/dnanmeanpn.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var ndarray = require( './ndarray.js' );
4545
* var Float64Array = require( '@stdlib/array/float64' );
4646
*
4747
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
48-
* var N = x.length;
4948
*
5049
* var v = dnanmeanpn( x.length, x, 1 );
5150
* // returns ~0.3333

lib/node_modules/@stdlib/stats/base/dnanmeanpn/lib/dnanmeanpn.native.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ var addon = require( './../src/addon.node' );
3737
* var Float64Array = require( '@stdlib/array/float64' );
3838
*
3939
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
40-
* var N = x.length;
4140
*
4241
* var v = dnanmeanpn( x.length, x, 1 );
4342
* // returns ~0.3333

lib/node_modules/@stdlib/stats/base/dnanmeanpn/lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
* var dnanmeanpn = require( '@stdlib/stats/base/dnanmeanpn' );
2929
*
3030
* var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
31-
* var N = 3;
3231
*
33-
* var v = dnanmeanpn( 5, x, 1 );
32+
* var v = dnanmeanpn( x.length, x, 1 );
3433
* // returns ~0.3333
3534
*
3635
* @example
@@ -39,7 +38,7 @@
3938
*
4039
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
4140
*
42-
* var v = dnanmeanpn.ndarray( 5, x, 2, 1 );
41+
* var v = dnanmeanpn.ndarray( 4, x, 2, 1 );
4342
* // returns 1.25
4443
*/
4544

lib/node_modules/@stdlib/stats/base/dnanmeanpn/lib/ndarray.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
* var Float64Array = require( '@stdlib/array/float64' );
4343
*
4444
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
45+
*
46+
* var v = dnanmeanpn( 4, x, 2, 1 );
47+
* // returns 1.25
4548
*/
4649
function dnanmeanpn( N, x, strideX, offsetX ) {
4750
var ix;

lib/node_modules/@stdlib/stats/base/dnanmeanpn/lib/ndarray.native.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ var addon = require( './../src/addon.node' );
3838
* var Float64Array = require( '@stdlib/array/float64' );
3939
*
4040
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
41+
*
42+
* var v = dnanmeanpn( 4, x, 2, 1 );
43+
* // returns 1.25
4144
*/
4245
function dnanmeanpn( N, x, strideX, offsetX ) {
4346
return addon.ndarray( N, x, strideX, offsetX );

lib/node_modules/@stdlib/stats/base/dnanmeanpn/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958).
3434
* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036).
3535
*
36-
* @param N number of indexed elements
37-
* @param X input array
38-
* @param stride stride length
39-
* @return output value
36+
* @param N number of indexed elements
37+
* @param X input array
38+
* @param strideX stride length
39+
* @return output value
4040
*/
4141
double API_SUFFIX(stdlib_strided_dnanmeanpn)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX ) {
4242
const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
4343
return API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( N, X, strideX, ox );
4444
}
4545

4646
/**
47-
* Computes the maximum absolute value of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.
47+
* Computes the arithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
4848
*
4949
* @param N number of indexed elements
5050
* @param X input array

0 commit comments

Comments
 (0)