Class HarmonicCurveFitter
java.lang.Object
org.apache.commons.math3.fitting.AbstractCurveFitter
org.apache.commons.math3.fitting.HarmonicCurveFitter
Fits points to a
The
harmonic oscillator
function.
The
initial guess values must be passed
in the following order:
- Amplitude
- Angular frequency
- phase
- Since:
- 3.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class guesses harmonic coefficients from a sample.Nested classes/interfaces inherited from class AbstractCurveFitter
AbstractCurveFitter.TheoreticalValuesFunction -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final HarmonicOscillator.ParametricParametric function to be fitted.private final double[]Initial guess.private final intMaximum number of iterations of the optimization algorithm. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateHarmonicCurveFitter(double[] initialGuess, int maxIter) Contructor used by the factory methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic HarmonicCurveFittercreate()Creates a default curve fitter.protected LeastSquaresProblemgetProblem(Collection<WeightedObservedPoint> observations) Creates a least squares problem corresponding to the appropriate curve.withMaxIterations(int newMaxIter) Configure the maximum number of iterations.withStartPoint(double[] newStart) Configure the start point (initial guess).Methods inherited from class AbstractCurveFitter
fit, getOptimizer
-
Field Details
-
FUNCTION
Parametric function to be fitted. -
initialGuess
private final double[] initialGuessInitial guess. -
maxIter
private final int maxIterMaximum number of iterations of the optimization algorithm.
-
-
Constructor Details
-
HarmonicCurveFitter
private HarmonicCurveFitter(double[] initialGuess, int maxIter) Contructor used by the factory methods.- Parameters:
initialGuess- Initial guess. If set tonull, the initial guess will be estimated using theHarmonicCurveFitter.ParameterGuesser.maxIter- Maximum number of iterations of the optimization algorithm.
-
-
Method Details
-
create
Creates a default curve fitter. The initial guess for the parameters will beHarmonicCurveFitter.ParameterGuessercomputed automatically, and the maximum number of iterations of the optimization algorithm is set toInteger.MAX_VALUE.- Returns:
- a curve fitter.
- See Also:
-
withStartPoint
Configure the start point (initial guess).- Parameters:
newStart- new start point (initial guess)- Returns:
- a new instance.
-
withMaxIterations
Configure the maximum number of iterations.- Parameters:
newMaxIter- maximum number of iterations- Returns:
- a new instance.
-
getProblem
Creates a least squares problem corresponding to the appropriate curve.- Specified by:
getProblemin classAbstractCurveFitter- Parameters:
observations- Sample points.- Returns:
- the least squares problem to use for fitting the curve to the
given
points.
-