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
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 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, 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( 4, 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 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 =newFloat64Array( [ 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 =dnanmeanpw.ndarray( N, x, 2, 1 );
122
+
var v =dnanmeanpw.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/dnanmeanpw.h"
183
+
```
184
+
185
+
#### stdlib_strided_dnanmeanpw( N, \*X, strideX )
186
+
187
+
Computes the [arithmetic mean][arithmetic-mean] of a double-precision floating-point strided array, ignoring `NaN` values and using pairwise summation.
188
+
189
+
```c
190
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
191
+
192
+
double v = stdlib_strided_dnanmeanpw( 4, x, 1 );
193
+
// returns ~0.3333
194
+
```
195
+
196
+
The function accepts the following arguments:
197
+
198
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
199
+
- **X**: `[in] double*` input array.
200
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dnanmeanpw_ndarray( N, \*X, strideX, offsetX )
207
+
208
+
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.
209
+
210
+
```c
211
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
212
+
213
+
double v = stdlib_strided_dnanmeanpw_ndarray( 4, x, 1, 0 );
214
+
// returns ~0.3333
215
+
```
216
+
217
+
The function accepts the following arguments:
218
+
219
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
220
+
- **X**: `[in] double*` input array.
221
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
222
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
double v = stdlib_strided_dnanmeanpw( N, x, strideX );
262
+
263
+
// Print the result:
264
+
printf( "mean: %lf\n", v );
265
+
}
266
+
```
267
+
268
+
</section>
269
+
270
+
<!-- /.examples -->
271
+
272
+
</section>
273
+
274
+
<!-- /.c -->
275
+
184
276
* * *
185
277
186
278
<section class="references">
@@ -201,7 +293,7 @@ console.log( v );
201
293
202
294
## See Also
203
295
204
-
- <spanclass="package-name">[`@stdlib/stats/base/dmeanpw`][@stdlib/stats/base/dmeanpw]</span><spanclass="delimiter">: </span><spanclass="description">calculate the arithmetic mean of a double-precision floating-point strided array using pairwise summation.</span>
296
+
- <span class="package-name">[`@stdlib/stats/base/dnanmeanpw`][@stdlib/stats/base/dnanmeanpw]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array using pairwise summation.</span>
205
297
- <span class="package-name">[`@stdlib/stats/base/dnanmean`][@stdlib/stats/base/dnanmean]</span><span class="delimiter">: </span><span class="description">calculate the arithmetic mean of a double-precision floating-point strided array, ignoring NaN values.</span>
0 commit comments