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
@@ -98,9 +98,9 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
98
98
var dnanstdevtk =require( '@stdlib/stats/base/dnanstdevtk' );
99
99
```
100
100
101
-
#### dnanstdevtk( N, correction, x, stride )
101
+
#### dnanstdevtk( 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 a one-pass textbook algorithm.
103
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass textbook algorithm.
@@ -116,41 +116,38 @@ 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 =dnanstdevtk( N, 1, x1, 2 );
144
+
var v =dnanstdevtk( 5, 1, x1, 2 );
148
145
// returns 2.5
149
146
```
150
147
151
-
#### dnanstdevtk.ndarray( N, correction, x, stride, offset )
148
+
#### dnanstdevtk.ndarray( N, correction, x, strideX, offsetX )
152
149
153
-
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array ignoring `NaN` values and using a one-pass textbook algorithm and alternative indexing semantics.
150
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass textbook algorithm and alternative indexing semantics.
@@ -163,18 +160,18 @@ var v = dnanstdevtk.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 dnanstdevtk =require( '@stdlib/stats/base/dnanstdevtk' );
208
205
209
-
var x;
210
-
var i;
211
-
212
-
x =newFloat64Array( 10 );
213
-
for ( i =0; i <x.length; i++ ) {
214
-
x[ i ] =round( (randu()*100.0) -50.0 );
206
+
functionrand() {
207
+
if ( bernoulli( 0.8 ) <1 ) {
208
+
returnNaN;
209
+
}
210
+
returnuniform( -50.0, 50.0 );
215
211
}
212
+
213
+
var x =filledarrayBy( 10, 'float64', rand );
216
214
console.log( x );
217
215
218
216
var v =dnanstdevtk( x.length, 1, x, 1 );
@@ -223,6 +221,125 @@ console.log( v );
223
221
224
222
<!-- /.examples -->
225
223
224
+
<!-- C interface documentation. -->
225
+
226
+
* * *
227
+
228
+
<sectionclass="c">
229
+
230
+
## C APIs
231
+
232
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
233
+
234
+
<sectionclass="intro">
235
+
236
+
</section>
237
+
238
+
<!-- /.intro -->
239
+
240
+
<!-- C usage documentation. -->
241
+
242
+
<sectionclass="usage">
243
+
244
+
### Usage
245
+
246
+
```c
247
+
#include"stdlib/stats/base/dnanstdevtk.h"
248
+
```
249
+
250
+
#### stdlib_strided_dnanstdevtk( N, correction, \*X, strideX )
251
+
252
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass textbook algorithm.
253
+
254
+
```c
255
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
256
+
257
+
double v = stdlib_strided_dnanstdevtk( 4, 1.0, x, 1 );
258
+
// returns ~4.3333
259
+
```
260
+
261
+
The function accepts the following arguments:
262
+
263
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
264
+
- **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).
265
+
- **X**: `[in] double*` input array.
266
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dnanstdevtk_ndarray( N, correction, \*X, strideX, offsetX )
273
+
274
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array, ignoring `NaN` values and using a one-pass textbook algorithm and alternative indexing semantics.
275
+
276
+
```c
277
+
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
278
+
279
+
double v = stdlib_strided_dnanstdevtk_ndarray( 4, 1.0, x, 1, 0 );
280
+
// returns ~4.3333
281
+
```
282
+
283
+
The function accepts the following arguments:
284
+
285
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
286
+
- **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).
287
+
- **X**: `[in] double*` input array.
288
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
289
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments