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,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
98
98
var dnanvariancepn =require( '@stdlib/stats/base/dnanvariancepn' );
99
99
```
100
100
101
-
#### dnanvariancepn( N, correction, x, strideX )
101
+
#### dnanvariancepn( N, correction, x, stride )
102
102
103
103
Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using a two-pass algorithm.
104
104
@@ -116,16 +116,18 @@ 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`,
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`,
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
141
144
142
-
var v =dnanvariancepn( 5, 1, x1, 2 );
145
+
varN=floor( x0.length/2 );
146
+
147
+
var v =dnanvariancepn( N, 1, x1, 2 );
143
148
// returns 6.25
144
149
```
145
150
146
-
#### dnanvariancepn.ndarray( N, correction, x, strideX, offsetX )
151
+
#### dnanvariancepn.ndarray( N, correction, x, stride, offset )
147
152
148
153
Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
149
154
@@ -158,16 +163,18 @@ var v = dnanvariancepn.ndarray( x.length, 1, x, 1, 0 );
158
163
159
164
The function has the following additional parameters:
160
165
161
-
-**offsetX**: starting index for `x`.
166
+
-**offset**: starting index for `x`.
162
167
163
-
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 element in `x` starting from the second element
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 dnanvariancepn =require( '@stdlib/stats/base/dnanvariancepn' );
200
207
201
-
functionrand() {
202
-
if ( bernoulli( 0.8 ) <1 ) {
203
-
returnNaN;
204
-
}
205
-
returnuniform( -50.0, 50.0 );
206
-
}
208
+
var x;
209
+
var i;
207
210
208
-
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
+
}
209
215
console.log( x );
210
216
211
217
var v =dnanvariancepn( x.length, 1, x, 1 );
@@ -216,125 +222,6 @@ console.log( v );
216
222
217
223
<!-- /.examples -->
218
224
219
-
<!-- C interface documentation. -->
220
-
221
-
* * *
222
-
223
-
<sectionclass="c">
224
-
225
-
## C APIs
226
-
227
-
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
228
-
229
-
<sectionclass="intro">
230
-
231
-
</section>
232
-
233
-
<!-- /.intro -->
234
-
235
-
<!-- C usage documentation. -->
236
-
237
-
<sectionclass="usage">
238
-
239
-
### Usage
240
-
241
-
```c
242
-
#include"stdlib/stats/base/dnanvariancepn.h"
243
-
```
244
-
245
-
#### stdlib_strided_dnanvariancepn( N, correction, \*X, strideX )
246
-
247
-
Computes the [variance][variance] of a double-precision floating-point strided array `x` ignoring `NaN` values and using a two-pass algorithm.
248
-
249
-
```c
250
-
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
251
-
252
-
double v = stdlib_strided_dnanvariancepn( 4, 1.0, x, 1 );
253
-
// returns ~4.3333
254
-
```
255
-
256
-
The function accepts the following arguments:
257
-
258
-
- **N**: `[in] CBLAS_INT` number of indexed elements.
259
-
- **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).
260
-
- **X**: `[in] double*` input array.
261
-
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dnanvariancepn_ndarray( N, correction, \*X, strideX, offsetX )
268
-
269
-
Computes the [variance][variance] of a double-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm and alternative indexing semantics.
270
-
271
-
```c
272
-
constdouble x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
273
-
274
-
double v = stdlib_strided_dnanvariancepn_ndarray( 4, 1.0, x, 1, 0 );
275
-
// returns ~4.3333
276
-
```
277
-
278
-
The function accepts the following arguments:
279
-
280
-
- **N**: `[in] CBLAS_INT` number of indexed elements.
281
-
- **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).
282
-
- **X**: `[in] double*` input array.
283
-
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
284
-
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments