MATH-1534: Use value that probably conforms to the original intent.
Thanks to Christoph Läubrich.
diff --git a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
index 711fc1d..4af1200 100644
--- a/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
+++ b/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java
@@ -294,11 +294,10 @@
private double[] basicGuess(WeightedObservedPoint[] points) {
final int maxYIdx = findMaxY(points);
final double n = points[maxYIdx].getY();
- final double m = points[maxYIdx].getX();
double fwhmApprox;
try {
- final double halfY = n + ((m - n) / 2);
+ final double halfY = 0.5 * n;
final double fwhmX1 = interpolateXAtY(points, maxYIdx, -1, halfY);
final double fwhmX2 = interpolateXAtY(points, maxYIdx, 1, halfY);
fwhmApprox = fwhmX2 - fwhmX1;
@@ -308,7 +307,7 @@
}
final double s = fwhmApprox / (2 * FastMath.sqrt(2 * FastMath.log(2)));
- return new double[] { n, m, s };
+ return new double[] { n, points[maxYIdx].getX(), s };
}
/**