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,84 +51,77 @@ The [arithmetic mean][arithmetic-mean] is defined as
51
51
var dnanmeanpw =require( '@stdlib/stats/base/dnanmeanpw' );
52
52
```
53
53
54
-
#### dnanmeanpw( N, x, stride )
54
+
#### dnanmeanpw( N, x, strideX )
55
55
56
56
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array `x`, ignoring `NaN` values and using pairwise summation.
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:
var floor =require( '@stdlib/math/base/special/floor' );
94
90
95
-
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
91
+
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
96
92
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
97
93
98
-
varN=floor( x0.length/2 );
99
-
100
-
var v =dnanmeanpw( N, x1, 2 );
94
+
var v =dnanmeanpw( 5, x1, 2 );
101
95
// returns 1.25
102
96
```
103
97
104
-
#### dnanmeanpw.ndarray( N, x, stride, offset )
98
+
#### dnanmeanpw.ndarray( N, x, strideX, offsetX )
105
99
106
100
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.
var x =newFloat64Array( [ 1.0, -2.0, NaN, 2.0 ] );
112
-
varN=x.length;
113
106
114
-
var v =dnanmeanpw.ndarray( N, x, 1, 0 );
107
+
var v =dnanmeanpw.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.
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 starting from the second element:
var dnanmeanpw =require( '@stdlib/stats/base/dnanmeanpw' );
162
155
163
-
var x;
164
-
var i;
165
-
166
-
x =newFloat64Array( 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 );
156
+
functionrand() {
157
+
if ( bernoulli( 0.8 ) <1 ) {
158
+
returnNaN;
172
159
}
160
+
returnuniform( -50.0, 50.0 );
173
161
}
162
+
163
+
var x =filledarrayBy( 10, 'float64', rand );
174
164
console.log( x );
175
165
176
166
var v =dnanmeanpw( x.length, x, 1 );
@@ -181,6 +171,107 @@ console.log( v );
181
171
182
172
<!-- /.examples -->
183
173
174
+
<!-- C usage documentation. -->
175
+
176
+
<sectionclass="usage">
177
+
178
+
### Usage
179
+
180
+
```c
181
+
#include"stdlib/stats/base/dnanmeanpw.h"
182
+
```
183
+
184
+
#### stdlib_strided_dnanmeanpw( N, \*X, strideX )
185
+
186
+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation.
187
+
188
+
```c
189
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
190
+
191
+
double v = stdlib_strided_dnanmeanpw( 4, x, 1 );
192
+
// returns ~0.3333
193
+
```
194
+
195
+
The function accepts the following arguments:
196
+
197
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
#### stdlib_strided_dnanmeanpw_ndarray( N, \*X, strideX, offsetX )
206
+
207
+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.
208
+
209
+
```c
210
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
211
+
212
+
double v = stdlib_strided_dnanmeanpw_ndarray( 4, x, 1, 0 );
213
+
// returns ~0.3333
214
+
```
215
+
216
+
The function accepts the following arguments:
217
+
218
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
0 commit comments