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 +117,16 @@ The function has the following parameters:
117
117
-**mean**: mean.
118
118
-**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`,
122
+
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 x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
145
142
146
-
varN=floor( x0.length/2 );
147
-
148
-
var v =dvarm( N, 1.25, 1, x1, 2 );
143
+
var v =dvarm( 4, 1.25, 1, x1, 2 );
149
144
// returns 6.25
150
145
```
151
146
152
-
#### dvarm.ndarray( N, mean, correction, x, stride, offset )
147
+
#### dvarm.ndarray( N, mean, correction, x, strideX, offsetX )
153
148
154
149
Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean` and using alternative indexing semantics.
155
150
@@ -164,18 +159,16 @@ var v = dvarm.ndarray( x.length, 1.0/3.0, 1, x, 1, 0 );
164
159
165
160
The function has the following additional parameters:
166
161
167
-
-**offset**: starting index for `x`.
162
+
-**offsetX**: starting index for `x`.
168
163
169
-
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
164
+
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' );
207
198
var dvarm =require( '@stdlib/stats/base/dvarm' );
208
199
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 );
215
-
}
200
+
var x =discreteUniform( 10, -50, 50, {
201
+
'dtype':'float64'
202
+
});
216
203
console.log( x );
217
204
218
205
var v =dvarm( x.length, 0.0, 1, x, 1 );
@@ -223,6 +210,127 @@ console.log( v );
223
210
224
211
<!-- /.examples -->
225
212
213
+
<!-- C interface documentation. -->
214
+
215
+
* * *
216
+
217
+
<sectionclass="c">
218
+
219
+
## C APIs
220
+
221
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
222
+
223
+
<sectionclass="intro">
224
+
225
+
</section>
226
+
227
+
<!-- /.intro -->
228
+
229
+
<!-- C usage documentation. -->
230
+
231
+
<sectionclass="usage">
232
+
233
+
### Usage
234
+
235
+
```c
236
+
#include"stdlib/stats/base/dvarm.h"
237
+
```
238
+
239
+
#### stdlib_strided_dvarm( N, mean, correction, \*X, strideX )
240
+
241
+
Computes the [variance][variance] of a double-precision floating-point strided array provided a known `mean`.
double v = stdlib_strided_dvarm( 4, 1.25, 1.0, x, 2 );
247
+
// returns 6.25
248
+
```
249
+
250
+
The function accepts the following arguments:
251
+
252
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
253
+
- **mean**: `[in] double` mean.
254
+
- **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).
255
+
- **X**: `[in] double*` input array.
256
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **N**: `[in] CBLAS_INT` number of indexed elements.
276
+
- **mean**: `[in] double` mean.
277
+
- **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).
278
+
- **X**: `[in] double*` input array.
279
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
280
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments