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/variancepn/README.md
+19-33Lines changed: 19 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -98,15 +98,14 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
98
98
var variancepn =require( '@stdlib/stats/base/variancepn' );
99
99
```
100
100
101
-
#### variancepn( N, correction, x, stride )
101
+
#### variancepn( N, correction, x, strideX )
102
102
103
-
Computes the [variance][variance] of a strided array `x`using a two-pass algorithm.
103
+
Computes the [variance][variance] of a strided array using a two-pass algorithm.
104
104
105
105
```javascript
106
106
var x = [ 1.0, -2.0, 2.0 ];
107
-
varN=x.length;
108
107
109
-
var v =variancepn( N, 1, x, 1 );
108
+
var v =variancepn( x.length, 1, x, 1 );
110
109
// returns ~4.3333
111
110
```
112
111
@@ -115,17 +114,14 @@ The function has the following parameters:
115
114
-**N**: number of indexed elements.
116
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. 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).
117
116
-**x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
118
-
-**stride**: index increment for `x`.
117
+
-**strideX**: stride length for `x`.
119
118
120
-
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`,
121
120
122
121
```javascript
123
-
var floor =require( '@stdlib/math/base/special/floor' );
124
-
125
122
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
126
-
varN=floor( x.length/2 );
127
123
128
-
var v =variancepn( N, 1, x, 2 );
124
+
var v =variancepn( 4, 1, x, 2 );
129
125
// returns 6.25
130
126
```
131
127
@@ -135,42 +131,35 @@ Note that indexing is relative to the first index. To introduce an offset, use [
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
142
137
143
-
varN=floor( x0.length/2 );
144
-
145
-
var v =variancepn( N, 1, x1, 2 );
138
+
var v =variancepn( 4, 1, x1, 2 );
146
139
// returns 6.25
147
140
```
148
141
149
-
#### variancepn.ndarray( N, correction, x, stride, offset )
142
+
#### variancepn.ndarray( N, correction, x, strideX, offsetX )
150
143
151
144
Computes the [variance][variance] of a strided array using a two-pass algorithm and alternative indexing semantics.
152
145
153
146
```javascript
154
147
var x = [ 1.0, -2.0, 2.0 ];
155
-
varN=x.length;
156
148
157
-
var v =variancepn.ndarray( N, 1, x, 1, 0 );
149
+
var v =variancepn.ndarray( x.length, 1, x, 1, 0 );
158
150
// returns ~4.33333
159
151
```
160
152
161
153
The function has the following additional parameters:
162
154
163
-
-**offset**: starting index for `x`.
155
+
-**offsetX**: starting index for `x`.
164
156
165
-
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 element in `x` starting from the second element
166
158
167
159
```javascript
168
-
var floor =require( '@stdlib/math/base/special/floor' );
169
-
170
160
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
171
-
varN=floor( x.length/2 );
172
161
173
-
var v =variancepn.ndarray( N, 1, x, 2, 1 );
162
+
var v =variancepn.ndarray( 4, 1, x, 2, 1 );
174
163
// returns 6.25
175
164
```
176
165
@@ -184,6 +173,7 @@ var v = variancepn.ndarray( N, 1, x, 2, 1 );
184
173
185
174
- If `N <= 0`, both functions return `NaN`.
186
175
- If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), 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]).
187
177
- Depending on the environment, the typed versions ([`dvariancepn`][@stdlib/stats/strided/dvariancepn], [`svariancepn`][@stdlib/stats/strided/svariancepn], etc.) are likely to be significantly more performant.
188
178
189
179
</section>
@@ -197,18 +187,12 @@ var v = variancepn.ndarray( N, 1, x, 2, 1 );
197
187
<!-- eslint no-undef: "error" -->
198
188
199
189
```javascript
200
-
var randu =require( '@stdlib/random/base/randu' );
201
-
var round =require( '@stdlib/math/base/special/round' );
0 commit comments