Skip to content

Commit cc27022

Browse files
committed
fix ESLint issue
1 parent f03ec53 commit cc27022

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ var v = variancewd.ndarray( N, 1, x, 2, 1 );
198198
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
199199
var variancewd = require( '@stdlib/stats/base/variancewd' );
200200

201-
202201
var x = discreteUniform( 10, -50, 50, {
203202
'dtype': 'float64'
204203
});

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,34 @@
1616
* limitations under the License.
1717
*/
1818

19+
'use strict';
20+
1921
/**
2022
* Computes the variance of a strided array using Welford's algorithm and accessors.
2123
*
2224
* @private
2325
* @param {PositiveInteger} N - number of indexed elements
2426
* @param {number} correction - degrees of freedom adjustment
25-
* @param {Object} x - input array object
27+
* @param {Object} x - input array-like object supporting the accessor protocol
2628
* @param {Collection} x.data - input array data
2729
* @param {Array<Function>} x.accessors - array element accessors
2830
* @param {integer} strideX - stride length
2931
* @param {NonNegativeInteger} offsetX - starting index
3032
* @returns {number} variance
33+
*
34+
* @example
35+
* function accessor( arr, idx ) {
36+
* return arr.get( idx );
37+
* }
38+
*
39+
* var x = {
40+
* data: [ 2.0, 4.0, 6.0, 8.0, 10.0 ],
41+
* get: function( i ) { return this.data[ i ]; }
42+
* };
43+
*
44+
* var v = variancewd( 5, 1, x, 1, 0 );
45+
* // returns 10.0
3146
*/
32-
33-
'use strict';
34-
3547
function variancewd(N, correction, x, strideX, offsetX) {
3648
var delta2;
3749
var xbuf;

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ function variancewd(N, correction, x, strideX, offsetX) {
8787
var o;
8888
var i;
8989

90-
if (N <= 0) {
91-
return NaN;
92-
}
93-
if (N === 1 || strideX === 0) {
94-
if (N - correction <= 0) {
95-
return NaN;
96-
}
97-
return 0.0;
98-
}
99-
n = N - correction;
100-
if (n <= 0) {
101-
return NaN;
102-
}
90+
if (N <= 0) {
91+
return NaN;
92+
}
93+
if (N === 1 || strideX === 0) {
94+
if (N - correction <= 0) {
95+
return NaN;
96+
}
97+
return 0.0;
98+
}
99+
n = N - correction;
100+
if (n <= 0) {
101+
return NaN;
102+
}
103103

104104
o = arraylike2object(x);
105105
if (o.accessorProtocol) {

0 commit comments

Comments
 (0)