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/nanvarianceyc/README.md
+27-32Lines changed: 27 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
98
98
var nanvarianceyc =require( '@stdlib/stats/base/nanvarianceyc' );
99
99
```
100
100
101
-
#### nanvarianceyc( N, correction, x, stride )
101
+
#### nanvarianceyc( N, correction, x, strideX )
102
102
103
103
Computes the [variance][variance] of a strided array `x` ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
104
104
@@ -114,61 +114,52 @@ The function has the following parameters:
114
114
-**N**: number of indexed elements.
115
115
-**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).
116
116
-**x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
117
-
-**stride**: index increment for `x`.
117
+
-**strideX**: stride length for `x`.
118
118
119
-
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`,
119
+
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 floor =require( '@stdlib/math/base/special/floor' );
138
134
139
-
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
135
+
var x0 =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
140
136
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
141
137
142
-
varN=floor( x0.length/2 );
143
-
144
-
var v =nanvarianceyc( N, 1, x1, 2 );
138
+
var v =nanvarianceyc( 5, 1, x1, 2 );
145
139
// returns 6.25
146
140
```
147
141
148
-
#### nanvarianceyc.ndarray( N, correction, x, stride, offset )
142
+
#### nanvarianceyc.ndarray( N, correction, x, strideX, offsetX )
149
143
150
144
Computes the [variance][variance] of a strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
151
145
152
146
```javascript
153
147
var x = [ 1.0, -2.0, NaN, 2.0 ];
154
148
155
-
var v =nanvarianceyc.ndarray( x.length, 1, x, 1, 0 );
149
+
var v =nanvarianceyc.ndarray( 4, 1, x, 1, 0 );
156
150
// returns ~4.33333
157
151
```
158
152
159
153
The function has the following additional parameters:
160
154
161
-
-**offset**: starting index for `x`.
155
+
-**offsetX**: starting index for `x`.
162
156
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 value in `x` starting from the second value
157
+
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 x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
169
-
varN=floor( x.length/2 );
170
-
171
-
var v =nanvarianceyc.ndarray( N, 1, x, 2, 1 );
162
+
var v =nanvarianceyc.ndarray( 5, 1, x, 2, 1 );
172
163
// returns 6.25
173
164
```
174
165
@@ -182,6 +173,7 @@ var v = nanvarianceyc.ndarray( N, 1, x, 2, 1 );
182
173
183
174
- If `N <= 0`, both functions return `NaN`.
184
175
- If `n - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment and `n` corresponds to the number of non-`NaN` indexed elements), both functions return `NaN`.
176
+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
185
177
- Depending on the environment, the typed versions ([`dnanvarianceyc`][@stdlib/stats/base/dnanvarianceyc], [`snanvarianceyc`][@stdlib/stats/base/snanvarianceyc], etc.) are likely to be significantly more performant.
186
178
187
179
</section>
@@ -195,18 +187,19 @@ var v = nanvarianceyc.ndarray( N, 1, x, 2, 1 );
* Computes the variance of a strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer and alternative indexing semantics.
48
53
*
49
54
* @param N - number of indexed elements
50
55
* @param correction - degrees of freedom adjustment
51
56
* @param x - input array
52
-
* @paramstride - stride length
53
-
* @paramoffset - starting index
57
+
* @paramstrideX - stride length
58
+
* @paramoffsetX - starting index
54
59
* @returns variance
55
60
*
56
61
* @example
@@ -59,7 +64,7 @@ interface Routine {
59
64
* var v = nanvarianceyc.ndarray( x.length, 1, x, 1, 0 );
0 commit comments