org.apache.commons.math.optimization.fitting

## Class GaussianFitter

- java.lang.Object
- - org.apache.commons.math.optimization.fitting.GaussianFitter

    public class GaussianFitter
    extends java.lang.Object

Fits points to a Gaussian function (that is, a `GaussianFunction`).

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);
      GaussianFunction fitFunction = fitter.fit();

Since:
  2.2
Version:
  $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $
See Also:
  `ParametricGaussianFunction`

### Field Summary

Fields
`private CurveFitter` `fitter` Fitter used for fitting.

### Constructor Summary

Constructors
Constructor and Description
`GaussianFitter(DifferentiableMultivariateVectorialOptimizer optimizer)` Constructs an instance using the specified optimizer.

### Method Summary

Methods
`void` `addObservedPoint(double x, double y)` Adds point (`x`, `y`) to list of observed points with a weight of 1.0.
`void` `addObservedPoint(double weight, double x, double y)` Adds point (`x`, `y`) to list of observed points with a weight of `weight`.
`protected GaussianParametersGuesser` `createParametersGuesser(WeightedObservedPoint[] observations)` Factory method to create a `GaussianParametersGuesser` instance initialized with the specified observations.
`GaussianFunction` `fit()` Fits Gaussian function to the observed points.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### fitter

    private final CurveFitter fitter

Fitter used for fitting.

### Constructor Detail

#### GaussianFitter

    public GaussianFitter(DifferentiableMultivariateVectorialOptimizer optimizer)

Constructs an instance using the specified optimizer.

Parameters:
  `optimizer` - optimizer to use for the fitting

### Method Detail

#### addObservedPoint

    public void addObservedPoint(double x,
                        double y)

Adds point (`x`, `y`) to list of observed points with a weight of 1.0.

Parameters:
  `x` - `x` point value
  `y` - `y` point value

#### addObservedPoint

    public void addObservedPoint(double weight,
                        double x,
                        double y)

Adds point (`x`, `y`) to list of observed points with a weight of `weight`.

Parameters:
  `weight` - weight assigned to point
  `x` - `x` point value
  `y` - `y` point value

#### fit

    public GaussianFunction fit()
                         throws FunctionEvaluationException,
                                OptimizationException

Fits Gaussian function to the observed points.

Returns:
  Gaussian function best fitting the observed points
Throws:
  `FunctionEvaluationException` - if `CurveFitter.fit` throws it
  `OptimizationException` - if `CurveFitter.fit` throws it
  `java.lang.IllegalArgumentException` - if `CurveFitter.fit` throws it
See Also:
  `CurveFitter`

#### createParametersGuesser

    protected GaussianParametersGuesser createParametersGuesser(WeightedObservedPoint[] observations)

Factory method to create a `GaussianParametersGuesser` instance initialized with the specified observations.

Parameters:
  `observations` - points used to initialize the created `GaussianParametersGuesser` instance
Returns:
  new `GaussianParametersGuesser` instance