Skip to content

Commit 2a4c967

Browse files
committed
solving eslint issue in main.js
1 parent d4d2f01 commit 2a4c967

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
121
# nanmvariance
222

323
> Compute a moving [unbiased sample variance][sample-variance] incrementally, ignoring `NaN` values.

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ function incrnanmvariance( W, mean ) {
131131
return M2 / n;
132132
}
133133

134-
135134
// Update the index for managing the circular buffer:
136135
i = ( i+1 ) % W;
137136

@@ -178,7 +177,7 @@ function incrnanmvariance( W, mean ) {
178177
buf[i] = x;
179178
return M2 / n;
180179
}
181-
180+
182181
/**
183182
* If provided a value, the accumulator function returns an updated unbiased sample variance, ignoring NaN values. If not provided a value, the accumulator function returns the current unbiased sample variance.
184183
*
@@ -199,7 +198,13 @@ function incrnanmvariance( W, mean ) {
199198

200199
// If incoming value is NaN, ignore it:
201200
if ( isnan( x ) ) {
202-
return ( N === 0 ) ? null : ( N < W ) ? M2 / N : M2 / W;
201+
if ( N === 0 ) {
202+
return null;
203+
}
204+
if (N < W) {
205+
return M2 / N;
206+
}
207+
return M2 / W;
203208
}
204209

205210
// Update the index for managing the circular buffer:
@@ -219,7 +224,7 @@ function incrnanmvariance( W, mean ) {
219224
}
220225

221226
// Case: outgoing value is NaN, which we need to simply replace without affecting the variance
222-
else if ( isnan( buf[ i ] ) ) {
227+
if ( isnan( buf[ i ] ) ) {
223228
buf[ i ] = x;
224229

225230
// Add the squared difference between the new value and mean
@@ -228,15 +233,13 @@ function incrnanmvariance( W, mean ) {
228233
}
229234

230235
// Case: standard update when neither incoming nor outgoing values are NaN
231-
else {
232-
tmp = buf[ i ];
236+
tmp = buf[ i ];
233237

234-
// Remove the contribution of the outgoing value
235-
M2 -= (tmp - mu) * (tmp - mu);
238+
// Remove the contribution of the outgoing value
239+
M2 -= ( tmp - mu ) * ( tmp - mu );
236240

237-
// Add the contribution of the incoming value
238-
M2 += (x - mu) * (x - mu);
239-
}
241+
// Add the contribution of the incoming value
242+
M2 += ( x - mu ) * ( x - mu );
240243

241244
buf[ i ] = x;
242245
return M2 / W;

0 commit comments

Comments
 (0)