Skip to content

Commit 46aa802

Browse files
committed
[Fixed lint issues]
1 parent 4c8ca68 commit 46aa802

File tree

6 files changed

+49
-36
lines changed

6 files changed

+49
-36
lines changed

lib/node_modules/@stdlib/stats/incr/nanmstdev/README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,39 @@ var accumulator = incrnanmstdev( 3, 5.0 );
6767

6868
#### accumulator( \[x] )
6969

70-
If provided an input value `x`, the accumulator function returns an updated [corrected sample standard deviation][standard-deviation]. If not provided an input value `x`, the accumulator function returns the current [corrected sample standard deviation][standard-deviation]. If provided `NaN`, the accumulator function ignores the value and returns the current [corrected sample standard deviation][standard-deviation].
70+
If provided an input value `x`, the accumulator function returns an updated [corrected sample standard deviation][standard-deviation]. If not provided an input value `x`, the accumulator function returns the current [corrected sample standard deviation][standard-deviation]. If provided `NaN`, the accumulator function ignores the value and returns the current [corrected sample standard deviation][standard-deviation] without updating the window.
7171

7272
```javascript
7373
var accumulator = incrnanmstdev( 3 );
7474

7575
var s = accumulator();
7676
// returns null
7777

78-
// Fill the window...
78+
// Fill the window with non-NaN values...
7979
s = accumulator( 2.0 ); // [2.0]
8080
// returns 0.0
8181

82-
s = accumulator( NaN ); // [2.0, NaN]
82+
s = accumulator( NaN ); // [2.0]
8383
// returns 0.0
8484

85-
s = accumulator( 3.0 ); // [2.0, NaN, 3.0]
85+
s = accumulator( 3.0 ); // [2.0, 3.0]
8686
// returns ~0.7071
8787

88+
s = accumulator( 5.0 ); // [2.0, 3.0, 5.0]
89+
// returns ~1.53
90+
8891
// Window begins sliding...
89-
s = accumulator( -7.0 ); // [NaN, 3.0, -7.0]
90-
// returns ~7.07
92+
s = accumulator( -7.0 ); // [3.0, 5.0, -7.0]
93+
// returns ~6.43
94+
95+
s = accumulator( NaN ); // [3.0, 5.0, -7.0]
96+
// returns ~6.43
9197

92-
s = accumulator( -5.0 ); // [3.0, -7.0, -5.0]
93-
// returns ~5.29
98+
s = accumulator( -5.0 ); // [5.0, -7.0, -5.0]
99+
// returns ~6.43
94100

95101
s = accumulator();
96-
// returns ~5.29
102+
// returns ~6.43
97103
```
98104

99105
</section>
@@ -104,7 +110,7 @@ s = accumulator();
104110

105111
## Notes
106112

107-
- Input values are **not** type checked. If provided `NaN`, the value is ignored and the accumulator function returns the current [corrected sample standard deviation][standard-deviation]. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function.
113+
- Input values are **not** type checked. If provided `NaN`, the value is ignored and the accumulator function returns the current [corrected sample standard deviation][standard-deviation] without updating the window. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function.
108114
- As `W` values are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values (excluding NaN values).
109115

110116
</section>
@@ -153,7 +159,7 @@ console.log( accumulator() );
153159
## See Also
154160

155161
- <span class="package-name">[`@stdlib/stats/incr/mstdev`][@stdlib/stats/incr/mstdev]</span><span class="delimiter">: </span><span class="description">compute a moving corrected sample standard deviation incrementally.</span>
156-
- <span class="package-name">[`@stdlib/stats/incr/nanmmean`][@stdlib/stats/incr/nanmmean]</span><span class="delimiter">: </span><span class="description">compute a moving arietic mean incrementally, iging NaN values.</span>
162+
- <span class="package-name">[`@stdlib/stats/incr/mmean`][@stdlib/stats/incr/mmean]</span><span class="delimiter">: </span><span class="description">compute a moving arietic mean incrementally, iging NaN values.</span>
157163
- <span class="package-name">[`@stdlib/stats/incr/msummary`][@stdlib/stats/incr/msummary]</span><span class="delimiter">: </span><span class="description">compute a moving statistical summary incrementally, ignoring NaN values.</span>
158164
- <span class="package-name">[`@stdlib/stats/incr/mvariance`][@stdlib/stats/incr/mvariance]</span><span class="delimiter">: </span><span class="description">compute a moving unbiased sample variance incrementally, ignoring NaN values.</span>
159165
- <span class="package-name">[`@stdlib/stats/incr/stdev`][@stdlib/stats/incr/stdev]</span><span class="delimiter">: </span><span class="description">compute a corrected sample standard deviation incrementally, ignoring NaN values.</span>

lib/node_modules/@stdlib/stats/incr/nanmstdev/docs/repl.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{alias}}( W[, mean] )
2+
23
Returns an accumulator function which incrementally computes a moving
34
corrected sample standard deviation, ignoring NaN values.
45

@@ -10,9 +11,9 @@
1011
accumulator function returns the current moving corrected sample standard
1112
deviation.
1213

13-
As `W` values are needed to fill the window buffer, the first `W-1` returned
14-
values are calculated from smaller sample sizes. Until the window is full,
15-
each returned value is calculated from all provided values.
14+
As `W` values are needed to fill the window buffer, the first `W-1`
15+
returned values are calculated from smaller sample sizes. Until the window
16+
is full, each returned value is calculated from all provided values.
1617

1718
NaN values are ignored during computation. If provided NaN, the
1819
accumulator returns the current corrected sample standard deviation.
@@ -52,5 +53,4 @@
5253

5354
See Also
5455
--------
55-
@stdlib/stats/incr/mstdev, @stdlib/stats/incr/nanstdev, @stdlib/stats/incr/nanvariance
56-
56+

lib/node_modules/@stdlib/stats/incr/nanmstdev/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type accumulator = ( x?: number ) => number | null;
3737
*
3838
* ## Notes
3939
*
40-
* - The `W` parameter defines the number of values over which to compute the moving sum.
40+
* - The `W` parameter defines the number of values over which to compute the moving corrected sample standard deviation.
4141
* - As `W` values are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.
4242
* - NaN values are ignored.
4343
*

lib/node_modules/@stdlib/stats/incr/nanmstdev/examples/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ accumulator = incrnanmstdev( 5 );
3232
// For each simulated datum, update the moving t-student standard deviation...
3333
console.log( '\nValue\tT-Student Stdev\n' );
3434
for ( i = 0; i < 100; i++ ) {
35-
v = randu() > 0.2 ? NaN : randu() * 100.0;
35+
v = ( randu() > 0.2 ) ? NaN : randu() * 100.0;
3636
s = accumulator( v );
37-
console.log( '%d\t%d', v.toFixed( 4 ),(s == null) ? NaN : s.toFixed( 4 ) );
37+
console.log( '%d\t%d', v.toFixed( 4 ), (s === null) ? NaN : s.toFixed( 4 ) );
3838
}

lib/node_modules/@stdlib/stats/incr/nanmstdev/lib/main.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ var incrmstdev = require( '@stdlib/stats/incr/mstdev' );
9292
*
9393
* ```tex
9494
* \begin{align*}
95-
* (N-1)(\Delta s^2) &= (x_N - x_0)(x_N + x_0) - (x_N - x_0)(\bar{x}_{i+1} + \bar{x}_{i})
95+
* (N-1)(\Delta s^2) &= (x_N - x_0)(x_N + x_0) - (x_N - x_0)(\bar{x}_{i+1} + \bar{x}_{i}) \\
9696
* &= (x_N - x_0)(x_N + x_0 - \bar{x}_{i+1} - \bar{x}_{i}) \\
9797
* &= (x_N - x_0)(x_N - \bar{x}_{i+1} + x_0 - \bar{x}_{i})
9898
* \end{align*}
@@ -141,15 +141,24 @@ function incrnanmstdev( W, mean ) {
141141
} else {
142142
acc = incrmstdev( W );
143143
}
144-
return function accumulator( x ) {
144+
return accumulator;
145+
146+
/**
147+
* If provided a value, the accumulator function returns an updated standard deviation. If not provided a value, the accumulator function returns the current standard deviation.
148+
*
149+
* @private
150+
* @param {number} [x] - new value
151+
* @returns {(number|null)} standard deviation or null
152+
*/
153+
function accumulator( x ) {
145154
if ( arguments.length === 0 ) {
146155
return acc();
147156
}
148157
if ( isnan( x ) ) {
149158
return acc();
150159
}
151160
return acc( x );
152-
};
161+
}
153162
}
154163

155164

lib/node_modules/@stdlib/stats/incr/nanmstdev/test/test.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
var tape = require( 'tape' );
2424
var abs = require( '@stdlib/math/base/special/abs' );
2525
var sqrt = require( '@stdlib/math/base/special/sqrt' );
26-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var randu = require( '@stdlib/random/base/randu' );
2827
var EPS = require( '@stdlib/constants/float64/eps' );
2928
var incrnanmstdev = require( './../lib' );
@@ -300,7 +299,6 @@ tape( 'if the window size is `1` and the mean is known, the accumulator function
300299
t.end();
301300
});
302301

303-
304302
tape( 'if provided a NaN, the accumulator function ignores it (unknown mean, W=1)', function test( t ) {
305303
var expected;
306304
var data;
@@ -318,7 +316,7 @@ tape( 'if provided a NaN, the accumulator function ignores it (unknown mean, W=1
318316
NaN, // NaN (ignored) -> 0
319317
5.6 // 5.6 -> 0
320318
];
321-
319+
322320
expected = [
323321
null,
324322
0.0,
@@ -335,7 +333,7 @@ tape( 'if provided a NaN, the accumulator function ignores it (unknown mean, W=1
335333
} else {
336334
t.equal( v, expected[ i ], 'returns expected value for window '+i );
337335
}
338-
336+
339337
// Test accumulator without arguments
340338
if (expected[i] === null) {
341339
t.equal( acc(), null, 'returns correct value for window '+i );
@@ -363,7 +361,7 @@ tape( 'if provided a NaN, the accumulator function ignores it (known mean, W=1)'
363361
NaN, // NaN (ignored) -> 1.0
364362
5.0 // 5.0 -> 0.0
365363
];
366-
364+
367365
expected = [
368366
null,
369367
2.0,
@@ -380,7 +378,7 @@ tape( 'if provided a NaN, the accumulator function ignores it (known mean, W=1)'
380378
} else {
381379
t.equal( v, expected[ i ], 'returns expected value for window '+i );
382380
}
383-
381+
384382
// Test accumulator without arguments
385383
if (expected[i] === null) {
386384
t.equal( acc(), null, 'returns correct value for window '+i );
@@ -394,23 +392,23 @@ tape( 'if provided a NaN, the accumulator function ignores it (known mean, W=1)'
394392
tape( 'if provided a sequence of NaN values, the accumulator function should continue to ignore them', function test( t ) {
395393
var acc;
396394
var v;
397-
395+
398396
acc = incrnanmstdev( 3 );
399-
397+
400398
v = acc( 2.0 );
401399
t.equal( v, 0.0, 'returns expected value' );
402-
400+
403401
v = acc( NaN );
404402
t.equal( v, 0.0, 'returns expected value' );
405-
403+
406404
v = acc( NaN );
407405
t.equal( v, 0.0, 'returns expected value' );
408-
406+
409407
v = acc( NaN );
410408
t.equal( v, 0.0, 'returns expected value' );
411-
409+
412410
v = acc( 3.0 );
413411
t.equal( v.toFixed(4), sqrt(0.5).toFixed(4), 'returns expected value' );
414-
412+
415413
t.end();
416-
});
414+
});

0 commit comments

Comments
 (0)