You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/stats/base/nanmean/README.md
+27-38Lines changed: 27 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -51,78 +51,67 @@ The [arithmetic mean][arithmetic-mean] is defined as
51
51
var nanmean =require( '@stdlib/stats/base/nanmean' );
52
52
```
53
53
54
-
#### nanmean( N, x, stride )
54
+
#### nanmean( N, x, strideX )
55
55
56
-
Computes the [arithmetic mean][arithmetic-mean] of a strided array`x`, ignoring `NaN` values.
56
+
Computes the [arithmetic mean][arithmetic-mean] of a strided array, ignoring `NaN` values.
57
57
58
58
```javascript
59
59
var x = [ 1.0, -2.0, NaN, 2.0 ];
60
-
varN=x.length;
61
60
62
-
var v =nanmean( N, x, 1 );
61
+
var v =nanmean( x.length, x, 1 );
63
62
// returns ~0.3333
64
63
```
65
64
66
65
The function has the following parameters:
67
66
68
67
-**N**: number of indexed elements.
69
68
-**x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
70
-
-**stride**: index increment for `x`.
69
+
-**strideX**: stride length for `x`.
71
70
72
-
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`,
71
+
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`,
73
72
74
73
```javascript
75
-
var floor =require( '@stdlib/math/base/special/floor' );
76
-
77
74
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ];
78
-
varN=floor( x.length/2 );
79
75
80
-
var v =nanmean( N, x, 2 );
76
+
var v =nanmean( 4, x, 2 );
81
77
// returns 1.25
82
78
```
83
79
84
80
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
var floor =require( '@stdlib/math/base/special/floor' );
91
86
92
-
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
87
+
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
93
88
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
94
89
95
-
varN=floor( x0.length/2 );
96
-
97
-
var v =nanmean( N, x1, 2 );
90
+
var v =nanmean( 5, x1, 2 );
98
91
// returns 1.25
99
92
```
100
93
101
-
#### nanmean.ndarray( N, x, stride, offset )
94
+
#### nanmean.ndarray( N, x, strideX, offsetX )
102
95
103
96
Computes the [arithmetic mean][arithmetic-mean] of a strided array, ignoring `NaN` values and using alternative indexing semantics.
104
97
105
98
```javascript
106
99
var x = [ 1.0, -2.0, NaN, 2.0 ];
107
-
varN=x.length;
108
100
109
-
var v =nanmean.ndarray( N, x, 1, 0 );
101
+
var v =nanmean.ndarray( x.length, x, 1, 0 );
110
102
// returns ~0.33333
111
103
```
112
104
113
105
The function has the following additional parameters:
114
106
115
-
-**offset**: starting index for `x`.
107
+
-**offsetX**: starting index for `x`.
116
108
117
-
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
109
+
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
118
110
119
111
```javascript
120
-
var floor =require( '@stdlib/math/base/special/floor' );
121
-
122
-
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ];
123
-
varN=floor( x.length/2 );
112
+
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ];
124
113
125
-
var v =nanmean.ndarray( N, x, 2, 1 );
114
+
var v =nanmean.ndarray( 5, x, 2, 1 );
126
115
// returns 1.25
127
116
```
128
117
@@ -136,6 +125,7 @@ var v = nanmean.ndarray( N, x, 2, 1 );
136
125
137
126
- If `N <= 0`, both functions return `NaN`.
138
127
- If every indexed element is `NaN`, both functions return `NaN`.
128
+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
139
129
- Depending on the environment, the typed versions ([`dnanmean`][@stdlib/stats/strided/dnanmean], [`snanmean`][@stdlib/stats/base/snanmean], etc.) are likely to be significantly more performant.
140
130
141
131
</section>
@@ -149,22 +139,19 @@ var v = nanmean.ndarray( N, x, 2, 1 );
0 commit comments