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
@@ -117,18 +116,16 @@ The function has the following parameters:
117
116
-**N**: number of indexed elements.
118
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. 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 `x` 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 the strided array are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
var v =dvariancepn.ndarray( x.length, 1, x, 1, 0 );
163
156
// returns ~4.33333
164
157
```
165
158
166
159
The function has the following additional parameters:
167
160
168
-
-**offset**: starting index for `x`.
161
+
-**offsetX**: starting index for `x`.
169
162
170
-
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
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
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
208
197
var dvariancepn =require( '@stdlib/stats/base/dvariancepn' );
209
198
210
-
var x;
211
-
var i;
212
-
213
-
x =newFloat64Array( 10 );
214
-
for ( i =0; i <x.length; i++ ) {
215
-
x[ i ] =round( (randu()*100.0) -50.0 );
216
-
}
199
+
var x =discreteUniform( 10, -50, 50, {
200
+
'dtype':'float64'
201
+
});
217
202
console.log( x );
218
203
219
204
var v =dvariancepn( x.length, 1, x, 1 );
@@ -224,6 +209,125 @@ console.log( v );
224
209
225
210
<!-- /.examples -->
226
211
212
+
<!-- C interface documentation. -->
213
+
214
+
* * *
215
+
216
+
<sectionclass="c">
217
+
218
+
## C APIs
219
+
220
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
221
+
222
+
<sectionclass="intro">
223
+
224
+
</section>
225
+
226
+
<!-- /.intro -->
227
+
228
+
<!-- C usage documentation. -->
229
+
230
+
<sectionclass="usage">
231
+
232
+
### Usage
233
+
234
+
```c
235
+
#include"stdlib/stats/base/dvariancepn.h"
236
+
```
237
+
238
+
#### stdlib_strided_dvariancepn( N, correction, \*X, strideX )
239
+
240
+
Computes the [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm.
double v = stdlib_strided_dvariancepn( 8, 1.0, x, 1 );
246
+
// returns 6.0
247
+
```
248
+
249
+
The function accepts the following arguments:
250
+
251
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
252
+
- **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. 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).
253
+
- **X**: `[in] double*` input array.
254
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
double v = stdlib_strided_dvariancepn_ndarray( 4, 1.0, x, 2, 0 );
268
+
// returns ~6.666667
269
+
```
270
+
271
+
The function accepts the following arguments:
272
+
273
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
274
+
- **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. 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).
275
+
- **X**: `[in] double*` input array.
276
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
277
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments