Class SimpleCurveFitter
- java.lang.Object
-
- org.apache.commons.math4.legacy.fitting.AbstractCurveFitter
-
- org.apache.commons.math4.legacy.fitting.SimpleCurveFitter
-
- Direct Known Subclasses:
GaussianCurveFitter
,HarmonicCurveFitter
,PolynomialCurveFitter
public class SimpleCurveFitter extends AbstractCurveFitter
Fits points to a user-definedfunction
.- Since:
- 3.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleCurveFitter.ParameterGuesser
Guesses the parameters.-
Nested classes/interfaces inherited from class org.apache.commons.math4.legacy.fitting.AbstractCurveFitter
AbstractCurveFitter.TheoreticalValuesFunction
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleCurveFitter(ParametricUnivariateFunction function, double[] initialGuess, SimpleCurveFitter.ParameterGuesser guesser, int maxIter)
Constructor used by the factory methods.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleCurveFitter
create(ParametricUnivariateFunction f, double[] start)
Creates a curve fitter.static SimpleCurveFitter
create(ParametricUnivariateFunction f, SimpleCurveFitter.ParameterGuesser guesser)
Creates a curve fitter.protected LeastSquaresProblem
getProblem(Collection<WeightedObservedPoint> observations)
Creates a least squares problem corresponding to the appropriate curve.SimpleCurveFitter
withMaxIterations(int newMaxIter)
Configure the maximum number of iterations.SimpleCurveFitter
withStartPoint(double[] newStart)
Configure the start point (initial guess).-
Methods inherited from class org.apache.commons.math4.legacy.fitting.AbstractCurveFitter
fit, getOptimizer
-
-
-
-
Constructor Detail
-
SimpleCurveFitter
protected SimpleCurveFitter(ParametricUnivariateFunction function, double[] initialGuess, SimpleCurveFitter.ParameterGuesser guesser, int maxIter)
Constructor used by the factory methods.- Parameters:
function
- Function to fit.initialGuess
- Initial guess. Cannot benull
. Its length must be consistent with the number of parameters of thefunction
to fit.guesser
- Method for providing an initial guess (ifinitialGuess
isnull
).maxIter
- Maximum number of iterations of the optimization algorithm.
-
-
Method Detail
-
create
public static SimpleCurveFitter create(ParametricUnivariateFunction f, double[] start)
Creates a curve fitter. The maximum number of iterations of the optimization algorithm is set toInteger.MAX_VALUE
.- Parameters:
f
- Function to fit.start
- Initial guess for the parameters. Cannot benull
. Its length must be consistent with the number of parameters of the function to fit.- Returns:
- a curve fitter.
- See Also:
withStartPoint(double[])
,withMaxIterations(int)
-
create
public static SimpleCurveFitter create(ParametricUnivariateFunction f, SimpleCurveFitter.ParameterGuesser guesser)
Creates a curve fitter. The maximum number of iterations of the optimization algorithm is set toInteger.MAX_VALUE
.- Parameters:
f
- Function to fit.guesser
- Method for providing an initial guess.- Returns:
- a curve fitter.
- See Also:
withStartPoint(double[])
,withMaxIterations(int)
-
withStartPoint
public SimpleCurveFitter withStartPoint(double[] newStart)
Configure the start point (initial guess).- Parameters:
newStart
- new start point (initial guess)- Returns:
- a new instance.
-
withMaxIterations
public SimpleCurveFitter withMaxIterations(int newMaxIter)
Configure the maximum number of iterations.- Parameters:
newMaxIter
- maximum number of iterations- Returns:
- a new instance.
-
getProblem
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations)
Creates a least squares problem corresponding to the appropriate curve.- Specified by:
getProblem
in classAbstractCurveFitter
- Parameters:
observations
- Sample points.- Returns:
- the least squares problem to use for fitting the curve to the
given
points
.
-
-