Gaussian
function.
initial guess values must be passed
in the following order:
Usage example:
WeightedObservedPoints obs = new WeightedObservedPoints(); obs.add(4.0254623, 531026.0); obs.add(4.03128248, 984167.0); obs.add(4.03839603, 1887233.0); obs.add(4.04421621, 2687152.0); obs.add(4.05132976, 3461228.0); obs.add(4.05326982, 3580526.0); obs.add(4.05779662, 3439750.0); obs.add(4.0636168, 2877648.0); obs.add(4.06943698, 2175960.0); obs.add(4.07525716, 1447024.0); obs.add(4.08237071, 717104.0); obs.add(4.08366408, 620014.0); double[] parameters = GaussianCurveFitter.create().fit(obs.toList());
| Modifier and Type | Class and Description |
|---|---|
| public static class | GaussianCurveFitter.
Guesses the parameters |
| Modifier and Type | Field and Description |
|---|---|
| private static final Gaussian. | FUNCTION
Parametric function to be fitted. |
| private final double[] | initialGuess
Initial guess. |
| private final int | maxIter
Maximum number of iterations of the optimization algorithm. |
| Access | Constructor and Description |
|---|---|
| private | GaussianCurveFitter(double[]
Initial guess. If set to initialGuess, int null, the initial guess
will be estimated using the ParameterGuesser.Maximum number of iterations of the optimization algorithm. maxIter)Contructor used by the factory methods. |
| Modifier and Type | Method and Description |
|---|---|
| public static GaussianCurveFitter | |
| protected LeastSquaresProblem | getProblem(Collection<WeightedObservedPoint>
Sample points. observations)Implements abstract org. Creates a least squares problem corresponding to the appropriate curve. |
| public GaussianCurveFitter | Returns: a new instance.maximum number of iterations newMaxIter)Configure the maximum number of iterations. |
| public GaussianCurveFitter | Returns: a new instance.new start point (initial guess) newStart)Configure the start point (initial guess). |
| FUNCTION | back to summary |
|---|---|
| private static final Gaussian. Parametric function to be fitted. | |
| initialGuess | back to summary |
|---|---|
| private final double[] initialGuess Initial guess. | |
| maxIter | back to summary |
|---|---|
| private final int maxIter Maximum number of iterations of the optimization algorithm. | |
| GaussianCurveFitter | back to summary |
|---|---|
| private GaussianCurveFitter(double[] initialGuess, int maxIter) Contructor used by the factory methods.
| |
| create | back to summary |
|---|---|
| public static GaussianCurveFitter create() Creates a default curve fitter.
The initial guess for the parameters will be
| |
| getProblem | back to summary |
|---|---|
| protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations) Implements abstract org. Doc from org. Creates a least squares problem corresponding to the appropriate curve.
| |
| withMaxIterations | back to summary |
|---|---|
| public GaussianCurveFitter withMaxIterations(int newMaxIter) Configure the maximum number of iterations.
| |
| withStartPoint | back to summary |
|---|---|
| public GaussianCurveFitter withStartPoint(double[] newStart) Configure the start point (initial guess).
| |
norm, mean, and sigma
of a org.apache.commons.math3.analysis.function.Gaussian.Parametric
based on the specified observed points.
| Modifier and Type | Field and Description |
|---|---|
| private final double | mean
Mean. |
| private final double | norm
Normalization factor. |
| private final double | sigma
Standard deviation. |
| Access | Constructor and Description |
|---|---|
| public | ParameterGuesser(Collection<WeightedObservedPoint>
Observed points from which to guess the
parameters of the Gaussian. observations)Constructs instance with the specified observed points. |
| Modifier and Type | Method and Description |
|---|---|
| private double[] | Returns: the guessed parameters (normalization factor, mean and sigma).Observed points, sorted. points)Guesses the parameters based on the specified observed points. |
| private int | Returns: the index in specified points array.Points to search. points)Finds index of point in specified points with the largest Y. |
| private WeightedObservedPoint[] | Returns: the array containing two points suitable for determining X at the specified Y.Points to use for interpolation. points, int Index within points from which to start search for
interpolation bounds points. startIdx, int Index step for search for interpolation bounds points. idxStep, double Y value for which X should be determined. y)Gets the two bounding interpolation points from the specified points suitable for determining X at the specified Y. |
| public double[] | Returns: the guessed parameters, in the following order:
Gets an estimation of the parameters. |
| private double | Returns: the value of X for the specified Y.Points to use for interpolation. points, int Index within points from which to start the search for
interpolation bounds points. startIdx, int Index step for searching interpolation bounds points. idxStep, double Y value for which X should be determined. y)Interpolates using the specified points to determine X at the specified Y. |
| private boolean | Returns: true if value is between boundary1 and
boundary2 (inclusive), false otherwise.Value to test whether it is between value, double boundary1
and boundary2.One end of the range. boundary1, double Other end of the range. boundary2)Determines whether a value is between two other values. |
| private List | Returns: the input observations, sorted.Input observations. unsorted)Sort the observations. |
| mean | back to summary |
|---|---|
| private final double mean Mean. | |
| norm | back to summary |
|---|---|
| private final double norm Normalization factor. | |
| sigma | back to summary |
|---|---|
| private final double sigma Standard deviation. | |
| ParameterGuesser | back to summary |
|---|---|
| public ParameterGuesser(Collection<WeightedObservedPoint> observations) Constructs instance with the specified observed points.
| |
| basicGuess | back to summary |
|---|---|
| private double[] basicGuess(WeightedObservedPoint[] points) Guesses the parameters based on the specified observed points.
| |
| findMaxY | back to summary |
|---|---|
| private int findMaxY(WeightedObservedPoint[] points) Finds index of point in specified points with the largest Y.
| |
| getInterpolationPointsForY | back to summary |
|---|---|
| private WeightedObservedPoint[] getInterpolationPointsForY(WeightedObservedPoint[] points, int startIdx, int idxStep, double y) throws OutOfRangeException Gets the two bounding interpolation points from the specified points suitable for determining X at the specified Y.
| |
| guess | back to summary |
|---|---|
| public double[] guess() Gets an estimation of the parameters.
| |
| interpolateXAtY | back to summary |
|---|---|
| private double interpolateXAtY(WeightedObservedPoint[] points, int startIdx, int idxStep, double y) throws OutOfRangeException Interpolates using the specified points to determine X at the specified Y.
| |
| isBetween | back to summary |
|---|---|
| private boolean isBetween(double value, double boundary1, double boundary2) Determines whether a value is between two other values.
| |
| sortObservations | back to summary |
|---|---|
| private List Sort the observations.
| |