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 dsnanmeanwd =require( '@stdlib/stats/base/dsnanmeanwd' );
52
52
```
53
53
54
-
#### dsnanmeanwd( N, x, stride )
54
+
#### dsnanmeanwd( N, x, strideX )
55
55
56
56
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x`, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result.
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 `x` 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 =dsnanmeanwd( N, x1, 2 );
94
+
var v =dsnanmeanwd( 4, x1, 2 );
101
95
// returns 1.25
102
96
```
103
97
104
-
#### dsnanmeanwd.ndarray( N, x, stride, offset )
98
+
#### dsnanmeanwd.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 Welford's algorithm 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 =dsnanmeanwd.ndarray( N, x, 1, 0 );
107
+
var v =dsnanmeanwd.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 floor =require( '@stdlib/math/base/special/floor' );
127
119
128
120
var x =newFloat32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
129
-
varN=floor( x.length/2 );
130
121
131
-
var v =dsnanmeanwd.ndarray( N, x, 2, 1 );
122
+
var v =dsnanmeanwd.ndarray( 4, x, 2, 1 );
132
123
// returns 1.25
133
124
```
134
125
@@ -181,6 +172,107 @@ console.log( v );
181
172
182
173
<!-- /.examples -->
183
174
175
+
<!-- C usage documentation. -->
176
+
177
+
<sectionclass="usage">
178
+
179
+
### Usage
180
+
181
+
```c
182
+
#include"stdlib/stats/base/dsnanmeanwd.h"
183
+
```
184
+
185
+
#### stdlib_strided_dsnanmeanwd( N, \*X, strideX )
186
+
187
+
Computes the arithmetic mean of a single-precision floating-point strided array `x`, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result.
#### stdlib_strided_dsnanmeanwd_ndarray( N, \*X, strideX, offsetX )
207
+
208
+
Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics.
0 commit comments