Skip to content

Commit

Permalink
Fix stdev in similar.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 12, 2021
1 parent cad0e3a commit 8b9cfb1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/stats/similar.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ export const haveSimilarMeans = function (
return
}

if (isPerfectStdev(stdevA, stdevB)) {
return meanA === meanB
}

return welchTTest({ meanA, stdevA, lengthA, meanB, stdevB, lengthB })
}

// When the result does not have enough measures, `stdev` and `envDev` are both
// `undefined`.
const hasImpreciseStdev = function (stdevA, stdevB) {
return (
stdevA === undefined ||
stdevB === undefined ||
(stdevA === 0 && stdevB === 0)
)
return stdevA === undefined || stdevB === undefined
}

// Retrieve the `length` of measures from `loops`.
Expand All @@ -103,6 +103,10 @@ const hasImpreciseLengths = function (lengthA, lengthB) {
return lengthA < 2 || lengthB < 2
}

const isPerfectStdev = function (stdevA, stdevB) {
return stdevA === 0 && stdevB === 0
}

const welchTTest = function ({
meanA,
stdevA,
Expand Down

0 comments on commit 8b9cfb1

Please sign in to comment.