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/dnanstdevwd/README.md
+147-30
Original file line number
Diff line number
Diff line change
@@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
98
98
var dnanstdevwd =require( '@stdlib/stats/base/dnanstdevwd' );
99
99
```
100
100
101
-
#### dnanstdevwd( N, correction, x, stride )
101
+
#### dnanstdevwd( N, correction, x, strideX )
102
102
103
-
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array`x` ignoring `NaN` values and using Welford's algorithm.
103
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm.
@@ -116,39 +116,36 @@ The function has the following parameters:
116
116
-**N**: number of indexed elements.
117
117
-**correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
121
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
var floor =require( '@stdlib/math/base/special/floor' );
141
140
142
-
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
141
+
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
143
142
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
144
143
145
-
varN=floor( x0.length/2 );
146
-
147
-
var v =dnanstdevwd( N, 1, x1, 2 );
144
+
var v =dnanstdevwd( 5, 1, x1, 2 );
148
145
// returns 2.5
149
146
```
150
147
151
-
#### dnanstdevwd.ndarray( N, correction, x, stride, offset )
148
+
#### dnanstdevwd.ndarray( N, correction, x, strideX, offsetX )
152
149
153
150
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics.
154
151
@@ -163,18 +160,18 @@ var v = dnanstdevwd.ndarray( x.length, 1, x, 1, 0 );
163
160
164
161
The function has the following additional parameters:
165
162
166
-
-**offset**: starting index for `x`.
163
+
-**offsetX**: starting index for `x`.
164
+
165
+
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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
167
166
168
-
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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
var dnanstdevwd =require( '@stdlib/stats/base/dnanstdevwd' );
207
204
208
-
var x;
209
-
var i;
210
-
211
-
x =newFloat64Array( 10 );
212
-
for ( i =0; i <x.length; i++ ) {
213
-
x[ i ] =round( (randu()*100.0) -50.0 );
205
+
functionrand() {
206
+
if ( bernoulli( 0.8 ) <1 ) {
207
+
returnNaN;
208
+
}
209
+
returnuniform( -50.0, 50.0 );
214
210
}
211
+
212
+
var x =filledarrayBy( 10, 'float64', rand );
215
213
console.log( x );
216
214
217
215
var v =dnanstdevwd( x.length, 1, x, 1 );
@@ -222,6 +220,125 @@ console.log( v );
222
220
223
221
<!-- /.examples -->
224
222
223
+
<!-- C interface documentation. -->
224
+
225
+
* * *
226
+
227
+
<sectionclass="c">
228
+
229
+
## C APIs
230
+
231
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
232
+
233
+
<sectionclass="intro">
234
+
235
+
</section>
236
+
237
+
<!-- /.intro -->
238
+
239
+
<!-- C usage documentation. -->
240
+
241
+
<sectionclass="usage">
242
+
243
+
### Usage
244
+
245
+
```c
246
+
#include"stdlib/stats/base/dnanstdevwd.h"
247
+
```
248
+
249
+
#### stdlib_strided_dnanstdevwd( N, correction, \*X, strideX )
250
+
251
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm.
252
+
253
+
```c
254
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
255
+
256
+
double v = stdlib_strided_dnanstdevwd( 4, 1.0, x, 1 );
257
+
// returns ~4.3333
258
+
```
259
+
260
+
The function accepts the following arguments:
261
+
262
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
263
+
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
264
+
- **X**: `[in] double*` input array.
265
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dnanstdevwd_ndarray( N, correction, \*X, strideX, offsetX )
272
+
273
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array ignoring `NaN` values and using Welford's algorithm and alternative indexing semantics.
274
+
275
+
```c
276
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
277
+
278
+
double v = stdlib_strided_dnanstdevwd_ndarray( 4, 1.0, x, 1, 0 );
279
+
// returns ~4.3333
280
+
```
281
+
282
+
The function accepts the following arguments:
283
+
284
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
285
+
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
286
+
- **X**: `[in] double*` input array.
287
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
288
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments