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
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/stats/base/dsvariance/README.md
+138-32
Original file line number
Diff line number
Diff line change
@@ -98,17 +98,16 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
98
98
var dsvariance =require( '@stdlib/stats/base/dsvariance' );
99
99
```
100
100
101
-
#### dsvariance( N, correction, x, stride )
101
+
#### dsvariance( N, correction, x, strideX )
102
102
103
-
Computes the [variance][variance] of a single-precision floating-point strided array `x`using extended accumulation and returning an extended precision result.
103
+
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
@@ -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 x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
145
141
146
-
varN=floor( x0.length/2 );
147
-
148
-
var v =dsvariance( N, 1, x1, 2 );
142
+
var v =dsvariance( 4, 1, x1, 2 );
149
143
// returns 6.25
150
144
```
151
145
152
-
#### dsvariance.ndarray( N, correction, x, stride, offset )
146
+
#### dsvariance.ndarray( N, correction, x, strideX, offsetX )
153
147
154
148
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
var v =dsvariance.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' );
209
198
var dsvariance =require( '@stdlib/stats/base/dsvariance' );
210
199
211
-
var x;
212
-
var i;
213
-
214
-
x =newFloat32Array( 10 );
215
-
for ( i =0; i <x.length; i++ ) {
216
-
x[ i ] =round( (randu()*100.0) -50.0 );
217
-
}
200
+
var x =discreteUniform( 10, -50, 50, {
201
+
'dtype':'float32'
202
+
});
218
203
console.log( x );
219
204
220
205
var v =dsvariance( x.length, 1, x, 1 );
@@ -225,6 +210,127 @@ console.log( v );
225
210
226
211
<!-- /.examples -->
227
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/dsvariance.h"
237
+
```
238
+
239
+
#### stdlib_strided_dsvariance( N, correction, \*X, strideX )
240
+
241
+
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and returning an extended precision result.
double v = stdlib_strided_dsvariance( 8, 1.0f, x, 1 );
247
+
// returns 6.0
248
+
```
249
+
250
+
The function accepts the following arguments:
251
+
252
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
253
+
- **correction**: `[in] float` 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).
254
+
- **X**: `[in] float*` input array.
255
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dsvariance_ndarray( N, correction, \*X, strideX, offsetX )
262
+
263
+
Computes the [variance][variance] of a single-precision floating-point strided array using extended accumulation and alternative indexing semantics and returning an extended precision result.
double v = stdlib_strided_dsvariance_ndarray( 4, 1.0f, x, 2, 0 );
269
+
// returns ~6.666667
270
+
```
271
+
272
+
The function accepts the following arguments:
273
+
274
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
275
+
- **correction**: `[in] float` 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).
276
+
- **X**: `[in] float*` input array.
277
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
278
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments