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/snanmeanpn/README.md
+146-37
Original file line number
Diff line number
Diff line change
@@ -51,84 +51,79 @@ The [arithmetic mean][arithmetic-mean] is defined as
51
51
var snanmeanpn =require( '@stdlib/stats/base/snanmeanpn' );
52
52
```
53
53
54
-
#### snanmeanpn( N, x, stride )
54
+
#### snanmeanpn( 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 a two-pass error correction algorithm.
56
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.
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`,
73
74
74
-
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
92
95
-
var x0 =newFloat32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
93
+
var x0 =newFloat32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
96
94
var x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
97
95
98
-
varN=floor( x0.length/2 );
99
-
100
-
var v =snanmeanpn( N, x1, 2 );
96
+
var v =snanmeanpn( 5, x1, 2 );
101
97
// returns 1.25
102
98
```
103
99
104
-
#### snanmeanpn.ndarray( N, x, stride, offset )
100
+
#### snanmeanpn.ndarray( N, x, strideX, offsetX )
105
101
106
102
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
var x =newFloat32Array( [ 1.0, -2.0, NaN, 2.0 ] );
112
-
varN=x.length;
113
108
114
-
var v =snanmeanpn.ndarray( N, x, 1, 0 );
109
+
var v =snanmeanpn.ndarray( x.length, x, 1, 0 );
115
110
// returns ~0.33333
116
111
```
117
112
118
113
The function has the following additional parameters:
119
114
120
-
-**offset**: starting index for `x`.
115
+
-**offsetX**: starting index for `x`.
121
116
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
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 element in `x` starting from the second element
var snanmeanpn =require( '@stdlib/stats/base/snanmeanpn' );
161
156
162
-
var x;
163
-
var i;
164
-
165
-
x =newFloat32Array( 10 );
166
-
for ( i =0; i <x.length; i++ ) {
167
-
if ( randu() <0.2 ) {
168
-
x[ i ] =NaN;
169
-
} else {
170
-
x[ i ] =round( (randu()*100.0) -50.0 );
157
+
functionrand() {
158
+
if ( bernoulli( 0.8 ) <1 ) {
159
+
returnNaN;
171
160
}
161
+
returnuniform( -50.0, 50.0 );
172
162
}
163
+
164
+
var x =filledarrayBy( 10, 'float32', rand );
173
165
console.log( x );
174
166
175
167
var v =snanmeanpn( x.length, x, 1 );
@@ -180,6 +172,123 @@ console.log( v );
180
172
181
173
<!-- /.examples -->
182
174
175
+
<!-- C interface documentation. -->
176
+
177
+
* * *
178
+
179
+
<sectionclass="c">
180
+
181
+
## C APIs
182
+
183
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
184
+
185
+
<sectionclass="intro">
186
+
187
+
</section>
188
+
189
+
<!-- /.intro -->
190
+
191
+
<!-- C usage documentation. -->
192
+
193
+
<sectionclass="usage">
194
+
195
+
### Usage
196
+
197
+
```c
198
+
#include"stdlib/stats/base/snanmeanpn.h"
199
+
```
200
+
201
+
#### stdlib_strided_snanmeanpn( N, \*X, strideX )
202
+
203
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.
#### stdlib_strided_snanmeanpn_ndarray( N, \*X, strideX, offsetX )
223
+
224
+
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
0 commit comments