Skip to content

Commit fab55eb

Browse files
committed
fix README.md file
1 parent b1c8caf commit fab55eb

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lib/node_modules/@stdlib/stats/base/variancewd/README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,12 @@ The function has the following parameters:
116116
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
117117
- **strideX**: stride length for `x`.
118118

119-
The `N` and `strideX` 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 strideX parameters determine which elements in the strided array are accessed at runtime. For example, to compute the minimum value of every other element in `x`,
120120

121121
```javascript
122-
var floor = require( '@stdlib/math/base/special/floor' );
123122

124123
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
125-
var N = floor( x.length / 2 );
126-
127-
var v = variancewd( N, 1, x, 2 );
124+
var v = variancewd( 4, 1, x, 2 );
128125
// returns 6.25
129126
```
130127

@@ -134,18 +131,16 @@ Note that indexing is relative to the first index. To introduce an offset, use [
134131

135132
```javascript
136133
var Float64Array = require( '@stdlib/array/float64' );
137-
var floor = require( '@stdlib/math/base/special/floor' );
138134

139135
var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
140136
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
141137

142-
var N = floor( x0.length / 2 );
143138

144-
var v = variancewd( N, 1, x1, 2 );
139+
var v = variancewd( 4, 1, x1, 2 );
145140
// returns 6.25
146141
```
147142

148-
#### variancewd.ndarray( N, correction, x, strideX, offset )
143+
#### variancewd.ndarray( N, correction, x, strideX, offsetX )
149144

150145
Computes the [variance][variance] of a strided array using Welford's algorithm and alternative indexing semantics.
151146

@@ -160,15 +155,13 @@ The function has the following additional parameters:
160155

161156
- **offset**: starting index for `x`.
162157

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
158+
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 the strided array starting from the second element
164159

165160
```javascript
166-
var floor = require( '@stdlib/math/base/special/floor' );
167161

168162
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
169-
var N = floor( x.length / 2 );
170163

171-
var v = variancewd.ndarray( N, 1, x, 2, 1 );
164+
var v = variancewd.ndarray( 4, 1, x, 2, 1 );
172165
// returns 6.25
173166
```
174167

@@ -181,6 +174,7 @@ var v = variancewd.ndarray( N, 1, x, 2, 1 );
181174
## Notes
182175

183176
- If `N <= 0`, both functions return `NaN`.
177+
- 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]).
184178
- If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both functions return `NaN`.
185179
- Depending on the environment, the typed versions ([`dvariancewd`][@stdlib/stats/base/dvariancewd], [`svariancewd`][@stdlib/stats/base/svariancewd], etc.) are likely to be significantly more performant.
186180

@@ -199,7 +193,7 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
199193
var variancewd = require( '@stdlib/stats/base/variancewd' );
200194

201195
var x = discreteUniform( 10, -50, 50, {
202-
'dtype': 'float64'
196+
y'dtype': 'float64'
203197
});
204198
console.log( x );
205199

@@ -233,6 +227,7 @@ console.log( v );
233227
## See Also
234228

235229
- <span class="package-name">[`@stdlib/stats/base/dvariancewd`][@stdlib/stats/base/dvariancewd]</span><span class="delimiter">: </span><span class="description">calculate the variance of a double-precision floating-point strided array using Welford's algorithm.</span>
230+
- <span class="package-name">[`@stdlib/stats/base/nanvariancewd`][@stdlib/stats/base/nanvariancewd]</span><span class="delimiter">: </span><span class="description">calculate the variance of a strided array ignoring NaN values and using Welford's algorithm.</span>
236231
- <span class="package-name">[`@stdlib/stats/base/stdevwd`][@stdlib/stats/base/stdevwd]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a strided array using Welford's algorithm.</span>
237232
- <span class="package-name">[`@stdlib/stats/base/variance`][@stdlib/stats/base/variance]</span><span class="delimiter">: </span><span class="description">calculate the variance of a strided array.</span>
238233

@@ -262,6 +257,8 @@ console.log( v );
262257

263258
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
264259

260+
[@stdlib/stats/base/nanvariancewd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanvariancewd
261+
265262
[@stdlib/stats/base/stdevwd]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/stdevwd
266263

267264
[@stdlib/stats/base/variance]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/variance

lib/node_modules/@stdlib/stats/base/variancewd/lib/accessors.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@
3232
* @returns {number} variance
3333
*
3434
* @example
35+
* function accessor(arr, idx) {
36+
* return arr[idx];
37+
* }
38+
*
3539
* var x = {
3640
* data: [ 2.0, 4.0, 6.0, 8.0 ],
37-
* accessors: [ function get(arr, idx) { return arr[idx]; } ]
41+
* accessors: [ accessor ]
3842
* };
3943
* var v = variancewd( x.data.length, 1, x, 1, 0 );
4044
* // returns 10.0

0 commit comments

Comments
 (0)