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/nanmeanors/README.md
+28-39Lines changed: 28 additions & 39 deletions
Display the source diff
Display the rich diff
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 nanmeanors =require( '@stdlib/stats/base/nanmeanors' );
52
52
```
53
53
54
-
#### nanmeanors( N, x, stride )
54
+
#### nanmeanors( N, x, strideX )
55
55
56
-
Computes the [arithmetic mean][arithmetic-mean] of a strided array`x`, ignoring `NaN` values and using ordinary recursive summation.
56
+
Computes the [arithmetic mean][arithmetic-mean] of a strided array, ignoring `NaN` values and using ordinary recursive summation.
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 =nanmeanors( N, x, 1 );
61
+
var v =nanmeanors( 4, 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`,
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 =nanmeanors( N, x1, 2 );
90
+
var v =nanmeanors( 5, x1, 2 );
98
91
// returns 1.25
99
92
```
100
93
101
-
#### nanmeanors.ndarray( N, x, stride, offset )
94
+
#### nanmeanors.ndarray( N, x, strideX, offsetX )
102
95
103
96
Computes the [arithmetic mean][arithmetic-mean] of a strided array, ignoring `NaN` values and using ordinary recursive summation and 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 =nanmeanors.ndarray( N, x, 1, 0 );
101
+
var v =nanmeanors.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 value in `x` starting from the second value
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 );
124
-
125
-
var v =nanmeanors.ndarray( N, x, 2, 1 );
114
+
var v =nanmeanors.ndarray( 5, x, 2, 1 );
126
115
// returns 1.25
127
116
```
128
117
@@ -137,6 +126,7 @@ var v = nanmeanors.ndarray( N, x, 2, 1 );
137
126
- If `N <= 0`, both functions return `NaN`.
138
127
- If every indexed element is `NaN`, both functions return `NaN`.
139
128
- Ordinary recursive summation (i.e., a "simple" sum) is performant, but can incur significant numerical error. If performance is paramount and error tolerated, using ordinary recursive summation to compute an arithmetic mean is acceptable; in all other cases, exercise due caution.
129
+
- 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]).
140
130
- Depending on the environment, the typed versions ([`dnanmeanors`][@stdlib/stats/strided/dnanmeanors], [`snanmeanors`][@stdlib/stats/strided/snanmeanors], etc.) are likely to be significantly more performant.
141
131
142
132
</section>
@@ -150,22 +140,19 @@ var v = nanmeanors.ndarray( N, x, 2, 1 );
0 commit comments