Skip to content

Commit

Permalink
Fixed a bug related to geometric mean calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ozgunbabur committed Jan 25, 2024
1 parent 1942ec4 commit 60d4e42
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public OneDataChangeDetector makeACopy()
*/
public double foldChangeGeometricMean(double[] vals)
{
if (vals.length == 1) return vals[0];

double mult = 1;
int cnt = 0;
for (double val : vals)
Expand All @@ -96,7 +98,9 @@ public double foldChangeGeometricMean(double[] vals)
cnt++;
mult *= val < 0 ? -1 / val : val;
}
return Math.pow(mult, 1D / cnt);
double result = Math.pow(mult, 1D / cnt);
if (result < 1) result = - 1 / result;
return result;
}

public double maxOfAbs(double[] vals)
Expand Down

0 comments on commit 60d4e42

Please sign in to comment.