You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2020/05/27 00:10:31 UTC

[commons-math] 01/03: MATH-1534: Use value that probably conforms to the original intent.

This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git

commit 9f17f6de64d5f8376bb0eda601d8c2d730e70d5e
Author: Gilles Sadowski <gi...@gmail.com>
AuthorDate: Wed May 27 01:52:14 2020 +0200

    MATH-1534: Use value that probably conforms to the original intent.
    
    Thanks to Christoph Läubrich.
---
 .../java/org/apache/commons/math4/fitting/GaussianCurveFitter.java   | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

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 @@ public class GaussianCurveFitter extends AbstractCurveFitter {
         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 @@ public class GaussianCurveFitter extends AbstractCurveFitter {
             }
             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 };
         }
 
         /**