Top Description Inners Constructors Methods
org.apache.commons.math3.optimization.fitting

public Class GaussianFitter

extends CurveFitter<Gaussian.Parametric>
Class Inheritance
Annotations
@Deprecated
Imports
java.util.Arrays, .Comparator, org.apache.commons.math3.analysis.function.Gaussian, org.apache.commons.math3.exception.NullArgumentException, .NumberIsTooSmallException, .OutOfRangeException, .ZeroException, .NotStrictlyPositiveException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.optimization.DifferentiableMultivariateVectorOptimizer, org.apache.commons.math3.util.FastMath

Deprecated

As of 3.1 (to be removed in 4.0).

Fits points to a Gaussian function.

Usage example:

  GaussianFitter fitter = new GaussianFitter(
    new LevenbergMarquardtOptimizer());
  fitter.addObservedPoint(4.0254623,  531026.0);
  fitter.addObservedPoint(4.03128248, 984167.0);
  fitter.addObservedPoint(4.03839603, 1887233.0);
  fitter.addObservedPoint(4.04421621, 2687152.0);
  fitter.addObservedPoint(4.05132976, 3461228.0);
  fitter.addObservedPoint(4.05326982, 3580526.0);
  fitter.addObservedPoint(4.05779662, 3439750.0);
  fitter.addObservedPoint(4.0636168,  2877648.0);
  fitter.addObservedPoint(4.06943698, 2175960.0);
  fitter.addObservedPoint(4.07525716, 1447024.0);
  fitter.addObservedPoint(4.08237071, 717104.0);
  fitter.addObservedPoint(4.08366408, 620014.0);
  double[] parameters = fitter.fit();
Since
2.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
GaussianFitter.ParameterGuesser

Guesses the parameters norm, mean, and sigma of a org.apache.commons.math3.analysis.function.Gaussian.Parametric based on the specified observed points.

Constructor Summary

AccessConstructor and Description
public
GaussianFitter(DifferentiableMultivariateVectorOptimizer
Optimizer to use for the fitting.
optimizer
)
Deprecated as a consequence of DifferentiableMultivariateVectorOptimizer being deprecated.

Constructs an instance using the specified optimizer.

Method Summary

Modifier and TypeMethod and Description
public double[]

Returns:

the parameters of the Gaussian function that best fits the observed points (in the same order as above).
fit
(double[]
First guess values in the following order:
  • Norm
  • Mean
  • Sigma
initialGuess
)

Fits a Gaussian function to the observed points.

public double[]

Returns:

the parameters of the Gaussian function that best fits the observed points (in the same order as above).
fit
()

Fits a Gaussian function to the observed points.

Inherited from org.apache.commons.math3.optimization.fitting.CurveFitter:
addObservedPointaddObservedPointaddObservedPointclearObservationsfitfitgetObservations

Constructor Detail

GaussianFitterback to summary
public GaussianFitter(DifferentiableMultivariateVectorOptimizer optimizer)

Deprecated

as a consequence of DifferentiableMultivariateVectorOptimizer being deprecated. See corresponding docs for further information.

Constructs an instance using the specified optimizer.

Parameters
optimizer:DifferentiableMultivariateVectorOptimizer

Optimizer to use for the fitting.

Method Detail

fitback to summary
public double[] fit(double[] initialGuess)

Fits a Gaussian function to the observed points.

Parameters
initialGuess:double[]

First guess values in the following order:

  • Norm
  • Mean
  • Sigma
Returns:double[]

the parameters of the Gaussian function that best fits the observed points (in the same order as above).

Since
3.0
fitback to summary
public double[] fit()

Fits a Gaussian function to the observed points.

Returns:double[]

the parameters of the Gaussian function that best fits the observed points (in the same order as above).

org.apache.commons.math3.optimization.fitting back to summary

public Class GaussianFitter.ParameterGuesser

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.fitting.GaussianFitter.ParameterGuesser

Guesses the parameters norm, mean, and sigma of a org.apache.commons.math3.analysis.function.Gaussian.Parametric based on the specified observed points.

Field Summary

Modifier and TypeField and Description
private final double
mean

Mean.

private final double
norm

Normalization factor.

private final double
sigma

Standard deviation.

Constructor Summary

AccessConstructor and Description
public
ParameterGuesser(WeightedObservedPoint[]
Observed points from which to guess the parameters of the Gaussian.
observations
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

Constructs instance with the specified observed points.

Method Summary

Modifier and TypeMethod and Description
private double[]

Returns:

the guessed parameters (normalization factor, mean and sigma).
basicGuess
(WeightedObservedPoint[]
Observed points, sorted.
points
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

Guesses the parameters based on the specified observed points.

private int

Returns:

the index in specified points array.
findMaxY
(WeightedObservedPoint[]
Points to search.
points
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

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.
getInterpolationPointsForY
(WeightedObservedPoint[]
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
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

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:
  • Normalization factor
  • Mean
  • Standard deviation
guess
()

Gets an estimation of the parameters.

private double

Returns:

the value of X for the specified Y.
interpolateXAtY
(WeightedObservedPoint[]
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
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

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.
isBetween
(double
Value to test whether it is between boundary1 and boundary2.
value
,
double
One end of the range.
boundary1
,
double
Other end of the range.
boundary2
)

Determines whether a value is between two other values.

private WeightedObservedPoint[]

Returns:

the input observations, sorted.
sortObservations
(WeightedObservedPoint[]
Input observations.
unsorted
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

Sort the observations.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

meanback to summary
private final double mean

Mean.

normback to summary
private final double norm

Normalization factor.

sigmaback to summary
private final double sigma

Standard deviation.

Constructor Detail

ParameterGuesserback to summary
public ParameterGuesser(WeightedObservedPoint[] observations)

Deprecated

as a consequence of WeightedObservedPoint being deprecated. See corresponding docs for further information.

Constructs instance with the specified observed points.

Parameters
observations:WeightedObservedPoint[]

Observed points from which to guess the parameters of the Gaussian.

Exceptions
NullArgumentException:
if observations is null.
NumberIsTooSmallException:
if there are less than 3 observations.

Method Detail

basicGuessback to summary
private double[] basicGuess(WeightedObservedPoint[] points)

Deprecated

as a consequence of WeightedObservedPoint being deprecated. See corresponding docs for further information.

Guesses the parameters based on the specified observed points.

Parameters
points:WeightedObservedPoint[]

Observed points, sorted.

Returns:double[]

the guessed parameters (normalization factor, mean and sigma).

findMaxYback to summary
private int findMaxY(WeightedObservedPoint[] points)

Deprecated

as a consequence of WeightedObservedPoint being deprecated. See corresponding docs for further information.

Finds index of point in specified points with the largest Y.

Parameters
points:WeightedObservedPoint[]

Points to search.

Returns:int

the index in specified points array.

getInterpolationPointsForYback to summary
private WeightedObservedPoint[] getInterpolationPointsForY(WeightedObservedPoint[] points, int startIdx, int idxStep, double y) throws OutOfRangeException

Deprecated

as a consequence of WeightedObservedPoint being deprecated. See corresponding docs for further information.

Gets the two bounding interpolation points from the specified points suitable for determining X at the specified Y.

Parameters
points:WeightedObservedPoint[]

Points to use for interpolation.

startIdx:int

Index within points from which to start search for interpolation bounds points.

idxStep:int

Index step for search for interpolation bounds points.

y:double

Y value for which X should be determined.

Returns:WeightedObservedPoint[]

the array containing two points suitable for determining X at the specified Y.

Exceptions
OutOfRangeException:
if specified y is not within the range of the specified points.
ZeroException:
if idxStep is 0.
guessback to summary
public double[] guess()

Gets an estimation of the parameters.

Returns:double[]

the guessed parameters, in the following order:

  • Normalization factor
  • Mean
  • Standard deviation
interpolateXAtYback to summary
private double interpolateXAtY(WeightedObservedPoint[] points, int startIdx, int idxStep, double y) throws OutOfRangeException

Deprecated

as a consequence of WeightedObservedPoint being deprecated. See corresponding docs for further information.

Interpolates using the specified points to determine X at the specified Y.

Parameters
points:WeightedObservedPoint[]

Points to use for interpolation.

startIdx:int

Index within points from which to start the search for interpolation bounds points.

idxStep:int

Index step for searching interpolation bounds points.

y:double

Y value for which X should be determined.

Returns:double

the value of X for the specified Y.

Exceptions
OutOfRangeException:
if specified y is not within the range of the specified points.
ZeroException:
if idxStep is 0.
isBetweenback to summary
private boolean isBetween(double value, double boundary1, double boundary2)

Determines whether a value is between two other values.

Parameters
value:double

Value to test whether it is between boundary1 and boundary2.

boundary1:double

One end of the range.

boundary2:double

Other end of the range.

Returns:boolean

true if value is between boundary1 and boundary2 (inclusive), false otherwise.

sortObservationsback to summary
private WeightedObservedPoint[] sortObservations(WeightedObservedPoint[] unsorted)

Deprecated

as a consequence of WeightedObservedPoint being deprecated. See corresponding docs for further information.

Sort the observations.

Parameters
unsorted:WeightedObservedPoint[]

Input observations.

Returns:WeightedObservedPoint[]

the input observations, sorted.