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

public Class CurveFitter<T extends ParametricUnivariateFunction>

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.optimization.fitting.GaussianFitter, org.apache.commons.math3.optimization.fitting.HarmonicFitter, org.apache.commons.math3.optimization.fitting.PolynomialFitter
Annotations
@Deprecated
Type Parameters
<T>
Function to use for the fit.
Imports
java.util.ArrayList, .List, org.apache.commons.math3.analysis.DifferentiableMultivariateVectorFunction, .MultivariateMatrixFunction, .ParametricUnivariateFunction, org.apache.commons.math3.analysis.differentiation.DerivativeStructure, .MultivariateDifferentiableVectorFunction, org.apache.commons.math3.optimization.DifferentiableMultivariateVectorOptimizer, .MultivariateDifferentiableVectorOptimizer, .PointVectorValuePair

Deprecated

As of 3.1 (to be removed in 4.0).

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 and Inner Type Summary

Modifier and TypeClass and Description
private class
CurveFitter.OldTheoreticalValuesFunction

Deprecated
Vectorial function computing function theoretical values.
private class
CurveFitter.TheoreticalValuesFunction

Vectorial function computing function theoretical values.

Field Summary

Modifier and TypeField and Description
private final List<WeightedObservedPoint>
observations

Observed points.

private final DifferentiableMultivariateVectorOptimizer
oldOptimizer

Deprecated as of 3.1 replaced by optimizer
Optimizer to use for the fitting.
private final MultivariateDifferentiableVectorOptimizer
optimizer

Deprecated as a consequence of MultivariateDifferentiableVectorOptimizer being deprecated.
Optimizer to use for the fitting.

Constructor Summary

AccessConstructor and Description
public
CurveFitter(final DifferentiableMultivariateVectorOptimizer
optimizer to use for the fitting
optimizer
)

Simple constructor.

public
CurveFitter(final MultivariateDifferentiableVectorOptimizer
optimizer to use for the fitting
optimizer
)
Deprecated as a consequence of MultivariateDifferentiableVectorOptimizer being deprecated.

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public void
addObservedPoint(double
abscissa of the point
x
,
double
observed value of the point at x, after fitting we should have f(x) as close as possible to this value
y
)

Add an observed (x,y) point to the sample with unit weight.

public void
addObservedPoint(double
weight of the observed point in the fit
weight
,
double
abscissa of the point
x
,
double
observed value of the point at x, after fitting we should have f(x) as close as possible to this value
y
)

Add an observed weighted (x,y) point to the sample.

public void
addObservedPoint(WeightedObservedPoint
observed point to add
observed
)
Deprecated as a consequence of WeightedObservedPoint being deprecated.

Add an observed weighted (x,y) point to the sample.

public void
clearObservations()

Remove all observations.

public double[]

Returns:

the fitted parameters.
fit
(T
parametric function to fit.
f
,
final double[]
first guess of the function parameters.
initialGuess
)

Fit a curve.

public double[]

Returns:

the fitted parameters.
fit
(int
Maximum number of function evaluations.
maxEval
,
T
parametric function to fit.
f
,
final double[]
first guess of the function parameters.
initialGuess
)

Fit a curve.

public WeightedObservedPoint[]

Returns:

observed points
getObservations
()
Deprecated as a consequence of WeightedObservedPoint being deprecated.

Get the observed points.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

observationsback to summary
private final List<WeightedObservedPoint> observations

Observed points.

oldOptimizerback to summary
private final DifferentiableMultivariateVectorOptimizer oldOptimizer

Deprecated

as of 3.1 replaced by optimizer

Optimizer to use for the fitting.

Annotations
@Deprecated
optimizerback to summary
private final MultivariateDifferentiableVectorOptimizer optimizer

Deprecated

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

Optimizer to use for the fitting.

Constructor Detail

CurveFitterback to summary
public CurveFitter(final DifferentiableMultivariateVectorOptimizer optimizer)

Simple constructor.

Parameters
optimizer:DifferentiableMultivariateVectorOptimizer

optimizer to use for the fitting

Annotations
@Deprecated
CurveFitterback to summary
public CurveFitter(final MultivariateDifferentiableVectorOptimizer optimizer)

Deprecated

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

Simple constructor.

Parameters
optimizer:MultivariateDifferentiableVectorOptimizer

optimizer to use for the fitting

Since
3.1

Method Detail

addObservedPointback to summary
public void addObservedPoint(double x, double y)

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:double

abscissa of the point

y:double

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()
addObservedPointback to summary
public void addObservedPoint(double weight, double x, double y)

Add an observed weighted (x,y) point to the sample.

Parameters
weight:double

weight of the observed point in the fit

x:double

abscissa of the point

y:double

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()
addObservedPointback to summary
public void addObservedPoint(WeightedObservedPoint observed)

Deprecated

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

Add an observed weighted (x,y) point to the sample.

Parameters
observed:WeightedObservedPoint

observed point to add

See Also
addObservedPoint(double, double), addObservedPoint(double, double, double), getObservations()
clearObservationsback to summary
public void clearObservations()

Remove all observations.

fitback to summary
public double[] fit(T f, final double[] initialGuess)

Fit a curve. This method compute the coefficients of the curve that best fit the sample of observed points previously given through calls to the addObservedPoint method.

Parameters
f:T

parametric function to fit.

initialGuess:double[]

first guess of the function parameters.

Returns:double[]

the fitted parameters.

Exceptions
DimensionMismatchException:
if the start point dimension is wrong.
fitback to summary
public double[] fit(int maxEval, T f, final double[] initialGuess)

Fit a curve. This method compute the coefficients of the curve that best fit the sample of observed points previously given through calls to the addObservedPoint method.

Parameters
maxEval:int

Maximum number of function evaluations.

f:T

parametric function to fit.

initialGuess:double[]

first guess of the function parameters.

Returns:double[]

the fitted parameters.

Exceptions
TooManyEvaluationsException:
if the number of allowed evaluations is exceeded.
DimensionMismatchException:
if the start point dimension is wrong.
Since
3.0
getObservationsback to summary
public WeightedObservedPoint[] getObservations()

Deprecated

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

Get the observed points.

Returns:WeightedObservedPoint[]

observed points

See Also
addObservedPoint(double, double), addObservedPoint(double, double, double), addObservedPoint(WeightedObservedPoint)
org.apache.commons.math3.optimization.fitting back to summary

private Class CurveFitter.OldTheoreticalValuesFunction

extends Object
implements DifferentiableMultivariateVectorFunction
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.fitting.CurveFitter.OldTheoreticalValuesFunction
All Implemented Interfaces
org.apache.commons.math3.analysis.DifferentiableMultivariateVectorFunction, org.apache.commons.math3.analysis.MultivariateVectorFunction
Annotations
@Deprecated

Deprecated

Vectorial function computing function theoretical values.

Field Summary

Modifier and TypeField and Description
private final ParametricUnivariateFunction
f

Function to fit.

Constructor Summary

AccessConstructor and Description
pack-priv
OldTheoreticalValuesFunction(final ParametricUnivariateFunction
function to fit.
f
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public MultivariateMatrixFunction
public double[]
value(double[]
point at which the function must be evaluated
point
)

Implements org.apache.commons.math3.analysis.MultivariateVectorFunction.value.

Compute the value for the function at the given point.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fback to summary
private final ParametricUnivariateFunction f

Function to fit.

Constructor Detail

OldTheoreticalValuesFunctionback to summary
pack-priv OldTheoreticalValuesFunction(final ParametricUnivariateFunction f)

Simple constructor.

Parameters
f:ParametricUnivariateFunction

function to fit.

Method Detail

jacobianback to summary
public MultivariateMatrixFunction jacobian()

Implements org.apache.commons.math3.analysis.DifferentiableMultivariateVectorFunction.jacobian.

Doc from org.apache.commons.math3.analysis.DifferentiableMultivariateVectorFunction.jacobian.

Returns the jacobian function.

Returns:MultivariateMatrixFunction

the jacobian function

valueback to summary
public double[] value(double[] point)

Implements org.apache.commons.math3.analysis.MultivariateVectorFunction.value.

Doc from org.apache.commons.math3.analysis.MultivariateVectorFunction.value.

Compute the value for the function at the given point.

Parameters
point:double[]

point at which the function must be evaluated

Returns:double[]

function value for the given point

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

private Class CurveFitter.TheoreticalValuesFunction

extends Object
implements MultivariateDifferentiableVectorFunction
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.optimization.fitting.CurveFitter.TheoreticalValuesFunction
All Implemented Interfaces
org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableVectorFunction, org.apache.commons.math3.analysis.MultivariateVectorFunction

Vectorial function computing function theoretical values.

Field Summary

Modifier and TypeField and Description
private final ParametricUnivariateFunction
f

Function to fit.

Constructor Summary

AccessConstructor and Description
pack-priv
TheoreticalValuesFunction(final ParametricUnivariateFunction
function to fit.
f
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public double[]
value(double[]
point at which the function must be evaluated
point
)

Implements org.apache.commons.math3.analysis.MultivariateVectorFunction.value.

Compute the value for the function at the given point.

public DerivativeStructure[]
value(DerivativeStructure[]
point at which the function must be evaluated
point
)

Implements org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableVectorFunction.value.

Compute the value for the function at the given point.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fback to summary
private final ParametricUnivariateFunction f

Function to fit.

Constructor Detail

TheoreticalValuesFunctionback to summary
pack-priv TheoreticalValuesFunction(final ParametricUnivariateFunction f)

Simple constructor.

Parameters
f:ParametricUnivariateFunction

function to fit.

Method Detail

valueback to summary
public double[] value(double[] point)

Implements org.apache.commons.math3.analysis.MultivariateVectorFunction.value.

Doc from org.apache.commons.math3.analysis.MultivariateVectorFunction.value.

Compute the value for the function at the given point.

Parameters
point:double[]

point at which the function must be evaluated

Returns:double[]

function value for the given point

valueback to summary
public DerivativeStructure[] value(DerivativeStructure[] point)

Implements org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableVectorFunction.value.

Doc from org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableVectorFunction.value.

Compute the value for the function at the given point.

Parameters
point:DerivativeStructure[]

point at which the function must be evaluated

Returns:DerivativeStructure[]

function value for the given point