Skip to content

Commit 33d00a8

Browse files
committed
fix: correct variancepn README
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 19dd4ec commit 33d00a8

File tree

1 file changed

+16
-24
lines changed
  • lib/node_modules/@stdlib/stats/base/variancepn

1 file changed

+16
-24
lines changed

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

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2025 The Stdlib Authors.
5+
Copyright (c) 2020 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -98,15 +98,14 @@ The use of the term `n-1` is commonly referred to as Bessel's correction. Note,
9898
var variancepn = require( '@stdlib/stats/base/variancepn' );
9999
```
100100

101-
#### variancepn( N, correction, x, stride )
101+
#### variancepn( N, correction, x, strideX )
102102

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.
104104

105105
```javascript
106106
var x = [ 1.0, -2.0, 2.0 ];
107-
var N = x.length;
108107

109-
var v = variancepn( N, 1, x, 1 );
108+
var v = variancepn( x.length, 1, x, 1 );
110109
// returns ~4.3333
111110
```
112111

@@ -115,17 +114,14 @@ The function has the following parameters:
115114
- **N**: number of indexed elements.
116115
- **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).
117116
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
118-
- **stride**: index increment for `x`.
117+
- **strideX**: stride length for `x`.
119118

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`,
121120

122121
```javascript
123-
var floor = require( '@stdlib/math/base/special/floor' );
124-
125122
var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
126-
var N = floor( x.length / 2 );
127123

128-
var v = variancepn( N, 1, x, 2 );
124+
var v = variancepn( 4, 1, x, 2 );
129125
// returns 6.25
130126
```
131127

@@ -135,42 +131,35 @@ Note that indexing is relative to the first index. To introduce an offset, use [
135131

136132
```javascript
137133
var Float64Array = require( '@stdlib/array/float64' );
138-
var floor = require( '@stdlib/math/base/special/floor' );
139134

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

143-
var N = floor( x0.length / 2 );
144-
145-
var v = variancepn( N, 1, x1, 2 );
138+
var v = variancepn( 4, 1, x1, 2 );
146139
// returns 6.25
147140
```
148141

149-
#### variancepn.ndarray( N, correction, x, stride, offset )
142+
#### variancepn.ndarray( N, correction, x, strideX, offsetX )
150143

151144
Computes the [variance][variance] of a strided array using a two-pass algorithm and alternative indexing semantics.
152145

153146
```javascript
154147
var x = [ 1.0, -2.0, 2.0 ];
155-
var N = x.length;
156148

157-
var v = variancepn.ndarray( N, 1, x, 1, 0 );
149+
var v = variancepn.ndarray( x.length, 1, x, 1, 0 );
158150
// returns ~4.33333
159151
```
160152

161153
The function has the following additional parameters:
162154

163-
- **offset**: starting index for `x`.
155+
- **offsetX**: starting index for `x`.
164156

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
166158

167159
```javascript
168-
var floor = require( '@stdlib/math/base/special/floor' );
169-
170160
var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
171-
var N = floor( x.length / 2 );
172161

173-
var v = variancepn.ndarray( N, 1, x, 2, 1 );
162+
var v = variancepn.ndarray( 4, 1, x, 2, 1 );
174163
// returns 6.25
175164
```
176165

@@ -184,6 +173,7 @@ var v = variancepn.ndarray( N, 1, x, 2, 1 );
184173

185174
- If `N <= 0`, both functions return `NaN`.
186175
- 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]).
187177
- 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.
188178

189179
</section>
@@ -259,6 +249,8 @@ console.log( v );
259249

260250
[@schubert:2018a]: https://doi.org/10.1145/3221269.3223036
261251

252+
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
253+
262254
<!-- <related-links> -->
263255

264256
[@stdlib/stats/strided/dvariancepn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dvariancepn

0 commit comments

Comments
 (0)