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
@@ -122,21 +122,19 @@ The function has the following parameters:
122
122
-**N**: number of indexed elements.
123
123
-**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).
-**out**: output [`Float64Array`][@stdlib/array/float64] for storing results.
127
-
-**strideOut**: index increment for `out`.
127
+
-**strideOut**: stride length for `out`.
128
128
129
-
The `N` and `stride` parameters determine which elements are accessed at runtime. For example, to compute the [variance][variance] of every other element in `x`,
129
+
The `N` and stride parameters determine which elements in the strided arrays 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
153
150
154
151
var out0 =newFloat64Array( 4 );
155
152
var out1 =newFloat64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
156
153
157
-
varN=floor( x0.length/2 );
158
-
159
-
var v =dmeanvarpn( N, 1, x1, 2, out1, 1 );
154
+
var v =dmeanvarpn( 4, 1, x1, 2, out1, 1 );
160
155
// returns <Float64Array>[ 1.25, 6.25 ]
161
156
```
162
157
@@ -179,17 +174,15 @@ The function has the following additional parameters:
179
174
-**offsetX**: starting index for `x`.
180
175
-**offsetOut**: starting index for `out`.
181
176
182
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameters support indexing semantics based on a starting index. For example, to calculate the [mean][arithmetic-mean] and [variance][variance] for every other value in `x` starting from the second value
177
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on a starting index. For example, to calculate the [mean][arithmetic-mean] and [variance][variance] for every other element in `x` starting from the second element
var dmeanvarpn =require( '@stdlib/stats/base/dmeanvarpn' );
222
214
223
-
var out;
224
-
var x;
225
-
var i;
226
-
227
-
x =newFloat64Array( 10 );
228
-
for ( i =0; i <x.length; i++ ) {
229
-
x[ i ] =round( (randu()*100.0) -50.0 );
230
-
}
215
+
var x =discreteUniform( 10, -50, 50, {
216
+
'dtype':'float64'
217
+
});
231
218
console.log( x );
232
219
233
-
out =newFloat64Array( 2 );
220
+
varout =newFloat64Array( 2 );
234
221
dmeanvarpn( x.length, 1, x, 1, out, 1 );
235
222
console.log( out );
236
223
```
@@ -239,6 +226,135 @@ console.log( out );
239
226
240
227
<!-- /.examples -->
241
228
229
+
<!-- C interface documentation. -->
230
+
231
+
* * *
232
+
233
+
<sectionclass="c">
234
+
235
+
## C APIs
236
+
237
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
238
+
239
+
<sectionclass="intro">
240
+
241
+
</section>
242
+
243
+
<!-- /.intro -->
244
+
245
+
<!-- C usage documentation. -->
246
+
247
+
<sectionclass="usage">
248
+
249
+
### Usage
250
+
251
+
```c
252
+
#include"stdlib/stats/base/dmeanvarpn.h"
253
+
```
254
+
255
+
#### stdlib_strided_dmeanvarpn( N, correction, \*X, strideX, \*Out, strideOut )
256
+
257
+
Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm.
- **N**: `[in] CBLAS_INT` number of indexed elements.
269
+
- **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).
270
+
- **X**: `[in] double*` input array.
271
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
272
+
- **Out**: `[out] double*` output array.
273
+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm and alternative indexing semantics.
- **N**: `[in] CBLAS_INT` number of indexed elements.
293
+
- **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).
294
+
- **X**: `[in] double*` input array.
295
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
296
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
297
+
- **Out**: `[out] double*` output array.
298
+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
299
+
- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`.
0 commit comments