Package org.apache.commons.math3.fitting
Class CurveFitter<T extends ParametricUnivariateFunction>
- java.lang.Object
-
- org.apache.commons.math3.fitting.CurveFitter<T>
-
- Type Parameters:
T- Function to use for the fit.
- Direct Known Subclasses:
GaussianFitter,HarmonicFitter,PolynomialFitter
@Deprecated public class CurveFitter<T extends ParametricUnivariateFunction> extends java.lang.ObjectDeprecated.As of 3.3. Please useAbstractCurveFitterandWeightedObservedPointsinstead.Fitter for parametric univariate real functions y = f(x).
When a univariate real function y = f(x) does depend on some unknown parameters p0, p1 ... pn-1, this class can be used to find these parameters. It does this by fitting the curve so it remains very close to a set of observed points (x0, y0), (x1, y1) ... (xk-1, yk-1). This fitting is done by finding the parameters values that minimizes the objective function ∑(yi-f(xi))2. This is really a least squares problem.- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCurveFitter.TheoreticalValuesFunctionDeprecated.Vectorial function computing function theoretical values.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<WeightedObservedPoint>observationsDeprecated.Observed points.private MultivariateVectorOptimizeroptimizerDeprecated.Optimizer to use for the fitting.
-
Constructor Summary
Constructors Constructor Description CurveFitter(MultivariateVectorOptimizer optimizer)Deprecated.Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddObservedPoint(double x, double y)Deprecated.Add an observed (x,y) point to the sample with unit weight.voidaddObservedPoint(double weight, double x, double y)Deprecated.Add an observed weighted (x,y) point to the sample.voidaddObservedPoint(WeightedObservedPoint observed)Deprecated.Add an observed weighted (x,y) point to the sample.voidclearObservations()Deprecated.Remove all observations.double[]fit(int maxEval, T f, double[] initialGuess)Deprecated.Fit a curve.double[]fit(T f, double[] initialGuess)Deprecated.Fit a curve.WeightedObservedPoint[]getObservations()Deprecated.Get the observed points.
-
-
-
Field Detail
-
optimizer
private final MultivariateVectorOptimizer optimizer
Deprecated.Optimizer to use for the fitting.
-
observations
private final java.util.List<WeightedObservedPoint> observations
Deprecated.Observed points.
-
-
Constructor Detail
-
CurveFitter
public CurveFitter(MultivariateVectorOptimizer optimizer)
Deprecated.Simple constructor.- Parameters:
optimizer- Optimizer to use for the fitting.- Since:
- 3.1
-
-
Method Detail
-
addObservedPoint
public void addObservedPoint(double x, double y)Deprecated.Add an observed (x,y) point to the sample with unit weight.Calling this method is equivalent to call
addObservedPoint(1.0, x, y).- Parameters:
x- abscissa of the pointy- observed value of the point at x, after fitting we should have f(x) as close as possible to this value- See Also:
addObservedPoint(double, double, double),addObservedPoint(WeightedObservedPoint),getObservations()
-
addObservedPoint
public void addObservedPoint(double weight, double x, double y)Deprecated.Add an observed weighted (x,y) point to the sample.- Parameters:
weight- weight of the observed point in the fitx- abscissa of the pointy- observed value of the point at x, after fitting we should have f(x) as close as possible to this value- See Also:
addObservedPoint(double, double),addObservedPoint(WeightedObservedPoint),getObservations()
-
addObservedPoint
public void addObservedPoint(WeightedObservedPoint observed)
Deprecated.Add an observed weighted (x,y) point to the sample.- Parameters:
observed- observed point to add- See Also:
addObservedPoint(double, double),addObservedPoint(double, double, double),getObservations()
-
getObservations
public WeightedObservedPoint[] getObservations()
Deprecated.Get the observed points.- Returns:
- observed points
- See Also:
addObservedPoint(double, double),addObservedPoint(double, double, double),addObservedPoint(WeightedObservedPoint)
-
clearObservations
public void clearObservations()
Deprecated.Remove all observations.
-
fit
public double[] fit(T f, double[] initialGuess)
Deprecated.Fit a curve. This method compute the coefficients of the curve that best fit the sample of observed points previously given through calls to theaddObservedPointmethod.- Parameters:
f- parametric function to fit.initialGuess- first guess of the function parameters.- Returns:
- the fitted parameters.
- Throws:
DimensionMismatchException- if the start point dimension is wrong.
-
fit
public double[] fit(int maxEval, T f, double[] initialGuess)Deprecated.Fit a curve. This method compute the coefficients of the curve that best fit the sample of observed points previously given through calls to theaddObservedPointmethod.- Parameters:
f- parametric function to fit.initialGuess- first guess of the function parameters.maxEval- Maximum number of function evaluations.- Returns:
- the fitted parameters.
- Throws:
TooManyEvaluationsException- if the number of allowed evaluations is exceeded.DimensionMismatchException- if the start point dimension is wrong.- Since:
- 3.0
-
-