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
@@ -116,38 +116,41 @@ 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 [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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 the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
122
-
123
-
<!-- eslint-disable max-len -->
121
+
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
@@ -160,18 +163,18 @@ var v = dnanvariance.ndarray( x.length, 1, x, 1, 0 );
160
163
161
164
The function has the following additional parameters:
162
165
163
-
-**offsetX**: starting index for `x`.
166
+
-**offset**: starting index for `x`.
164
167
165
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 [variance][variance] for every other value in `x` starting from the second value
var dnanvariance =require( '@stdlib/stats/base/dnanvariance' );
204
207
205
-
functionrand() {
206
-
if ( bernoulli( 0.8 ) <1 ) {
207
-
returnNaN;
208
-
}
209
-
returnuniform( -50.0, 50.0 );
210
-
}
208
+
var x;
209
+
var i;
211
210
212
-
var x =filledarrayBy( 10, 'float64', rand );
211
+
x =newFloat64Array( 10 );
212
+
for ( i =0; i <x.length; i++ ) {
213
+
x[ i ] =round( (randu()*100.0) -50.0 );
214
+
}
213
215
console.log( x );
214
216
215
217
var v =dnanvariance( x.length, 1, x, 1 );
@@ -220,125 +222,6 @@ console.log( v );
220
222
221
223
<!-- /.examples -->
222
224
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/dnanvariance.h"
247
-
```
248
-
249
-
#### stdlib_strided_dnanvariance( N, correction, \*X, strideX )
250
-
251
-
Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values.
252
-
253
-
```c
254
-
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
255
-
256
-
double v = stdlib_strided_dnanvariance( 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 [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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_dnanvariance_ndarray( N, correction, \*X, strideX, offsetX )
272
-
273
-
Computes the [variance][variance] of a double-precision floating-point strided array, ignoring `NaN` values 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_dnanvariance_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 [variance][variance] according to `n-c` where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements. When computing the [variance][variance] 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 unbiased sample [variance][variance], 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