/** * Guesses the parameters based on the specified observed points. * * @param points Observed points, sorted. * @return the guessed parameters (normalization factor, mean and * sigma). */ 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 fwhmX1 = interpolateXAtY(points, maxYIdx, -1, halfY); final double fwhmX2 = interpolateXAtY(points, maxYIdx, 1, halfY); fwhmApprox = fwhmX2 - fwhmX1; } catch (OutOfRangeException e) { // TODO: Exceptions should not be used for flow control. fwhmApprox = points[points.length - 1].getX() - points[0].getX(); } final double s = fwhmApprox / (2 * Math.sqrt(2 * Math.log(2))); return new double[] { n, m, s }; }
/** * Guesses the parameters based on the specified observed points. * * @param points Observed points, sorted. * @return the guessed parameters (normalization factor, mean and * sigma). */ 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 fwhmX1 = interpolateXAtY(points, maxYIdx, -1, halfY); final double fwhmX2 = interpolateXAtY(points, maxYIdx, 1, halfY); fwhmApprox = fwhmX2 - fwhmX1; } catch (OutOfRangeException e) { // TODO: Exceptions should not be used for flow control. fwhmApprox = points[points.length - 1].getX() - points[0].getX(); } final double s = fwhmApprox / (2 * FastMath.sqrt(2 * FastMath.log(2))); return new double[] { n, m, s }; }
/** * Guesses the parameters based on the specified observed points. * * @param points Observed points, sorted. * @return the guessed parameters (normalization factor, mean and * sigma). */ 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 fwhmX1 = interpolateXAtY(points, maxYIdx, -1, halfY); final double fwhmX2 = interpolateXAtY(points, maxYIdx, 1, halfY); fwhmApprox = fwhmX2 - fwhmX1; } catch (OutOfRangeException e) { // TODO: Exceptions should not be used for flow control. fwhmApprox = points[points.length - 1].getX() - points[0].getX(); } final double s = fwhmApprox / (2 * FastMath.sqrt(2 * FastMath.log(2))); return new double[] { n, m, s }; }