Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 12, 2021
1 parent 23e7747 commit 6f61395
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/stats/cold.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,9 @@ const findClosestMean = function (array, { mean, minIndex, maxIndex, filter }) {
let closestMean = 0
let closestMeanDiff = Number.POSITIVE_INFINITY
let sum = 0
let index = -1
let filteredIndex = 0

while (filteredIndex !== maxIndex) {
index += 1
const value = array[index]

for (const value of array) {
if (!filter(value)) {
continue
}
Expand All @@ -149,6 +145,10 @@ const findClosestMean = function (array, { mean, minIndex, maxIndex, filter }) {
continue
}

if (filteredIndex === maxIndex) {
break
}

const incrementalMean = sum / filteredIndex
const meanDiff = Math.abs(mean - incrementalMean)

Expand Down

0 comments on commit 6f61395

Please sign in to comment.