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
@@ -51,36 +51,33 @@ The [arithmetic mean][arithmetic-mean] is defined as
51
51
var sdsnanmeanors =require( '@stdlib/stats/base/sdsnanmeanors' );
52
52
```
53
53
54
-
#### sdsnanmeanors( N, x, stride )
54
+
#### sdsnanmeanors( N, x, strideX )
55
55
56
-
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array`x`, ignoring `NaN` values and using ordinary recursive summation with extended accumulation.
56
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation.
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`,
var floor =require( '@stdlib/math/base/special/floor' );
94
90
95
91
var x0 =newFloat32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
96
92
var x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
97
93
98
-
varN=floor( x0.length/2 );
99
-
100
-
var v =sdsnanmeanors( N, x1, 2 );
94
+
var v =sdsnanmeanors( 4, x1, 2 );
101
95
// returns 1.25
102
96
```
103
97
104
-
#### sdsnanmeanors.ndarray( N, x, stride, offset )
98
+
#### sdsnanmeanors.ndarray( N, x, strideX, offsetX )
105
99
106
100
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
var x =newFloat32Array( [ 1.0, -2.0, NaN, 2.0 ] );
112
-
varN=x.length;
113
106
114
-
var v =sdsnanmeanors.ndarray( N, x, 1, 0 );
107
+
var v =sdsnanmeanors.ndarray( x.length, x, 1, 0 );
115
108
// returns ~0.33333
116
109
```
117
110
118
111
The function has the following additional parameters:
119
112
120
-
-**offset**: starting index for `x`.
113
+
-**offsetX**: starting index for `x`.
121
114
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
var sdsnanmeanors =require( '@stdlib/stats/base/sdsnanmeanors' );
162
153
163
-
var x;
164
-
var i;
165
-
166
-
x =newFloat32Array( 10 );
167
-
for ( i =0; i <x.length; i++ ) {
168
-
if ( randu() <0.2 ) {
169
-
x[ i ] =NaN;
170
-
} else {
171
-
x[ i ] =round( (randu()*100.0) -50.0 );
154
+
functionrand() {
155
+
if ( bernoulli( 0.8 ) <1 ) {
156
+
returnNaN;
172
157
}
158
+
returnuniform( -50.0, 50.0 );
173
159
}
160
+
161
+
var x =filledarrayBy( 10, 'float32', rand );
174
162
console.log( x );
175
163
176
164
var v =sdsnanmeanors( x.length, x, 1 );
@@ -181,6 +169,109 @@ console.log( v );
181
169
182
170
<!-- /.examples -->
183
171
172
+
<!-- C usage documentation. -->
173
+
174
+
* * *
175
+
176
+
<sectionclass="usage">
177
+
178
+
### Usage
179
+
180
+
```c
181
+
#include"stdlib/stats/base/sdsnanmeanors.h"
182
+
```
183
+
184
+
#### stdlib_strided_sdsnanmeanors( N, \*X, strideX )
185
+
186
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation.
#### stdlib_strided_sdsnanmeanors_ndarray( N, \*X, strideX, offsetX )
206
+
207
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using ordinary recursive summation with extended accumulation and alternative indexing semantics.
0 commit comments