Class HarmonicFitter
- java.lang.Object
-
- org.spaceroots.mantissa.fitting.AbstractCurveFitter
-
- org.spaceroots.mantissa.fitting.HarmonicFitter
-
- All Implemented Interfaces:
- java.io.Serializable, EstimationProblem
public class HarmonicFitter extends AbstractCurveFitter
This class implements a curve fitting specialized for sinusoids.Harmonic fitting is a very simple case of curve fitting. The estimated coefficients are the amplitude a, the pulsation omega and the phase phi:
f (t) = a cos (omega t + phi). They are searched by a least square estimator initialized with a rough guess based on integrals.This class
is by no means optimized , neither versus space nor versus time performance.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.spaceroots.mantissa.fitting.AbstractCurveFitter
AbstractCurveFitter.FitMeasurement
-
-
Constructor Summary
Constructors Constructor and Description HarmonicFitter(EstimatedParameter[] coefficients, Estimator estimator)Simple constructor.HarmonicFitter(EstimatedParameter[] coefficients, int maxIterations, double convergence, double steadyStateThreshold, double epsilon)Deprecated.replaced byHarmonicFitter(EstimatedParameter[], Estimator)as of version 7.0HarmonicFitter(Estimator estimator)Simple constructor.HarmonicFitter(int maxIterations, double convergence, double steadyStateThreshold, double epsilon)Deprecated.replaced byHarmonicFitter(Estimator)as of version 7.0
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[]fit()Perform the fitting.doublegetAmplitude()Get the current amplitude coefficient estimate.doublegetPhase()Get the current phase coefficient estimate.doublegetPulsation()Get the current pulsation coefficient estimate.doublepartial(double x, EstimatedParameter p)Get the derivative of the function at x with respect to parameter p.doublevalueAt(double x)Get the value of the function at x according to the current parameters value.-
Methods inherited from class org.spaceroots.mantissa.fitting.AbstractCurveFitter
addWeightedPair, getAllParameters, getMeasurements, getUnboundParameters
-
-
-
-
Constructor Detail
-
HarmonicFitter
public HarmonicFitter(Estimator estimator)
Simple constructor.- Parameters:
estimator- estimator to use for the fitting
-
HarmonicFitter
public HarmonicFitter(EstimatedParameter[] coefficients, Estimator estimator)
Simple constructor.This constructor can be used when a first estimate of the coefficients is already known.
- Parameters:
coefficients- first estimate of the coefficients. A reference to this array is hold by the newly created object. Its elements will be adjusted during the fitting process and they will be set to the adjusted coefficients at the end.estimator- estimator to use for the fitting
-
HarmonicFitter
public HarmonicFitter(int maxIterations, double convergence, double steadyStateThreshold, double epsilon)Deprecated. replaced byHarmonicFitter(Estimator)as of version 7.0Simple constructor.- Parameters:
maxIterations- maximum number of iterations allowedconvergence- criterion threshold below which we do not need to improve the criterion anymoresteadyStateThreshold- steady state detection threshold, the problem has reached a steady state (read converged) ifMath.abs (Jn - Jn-1) < Jn * convergence, whereJnandJn-1are the current and preceding criterion value (square sum of the weighted residuals of considered measurements).epsilon- threshold under which the matrix of the linearized problem is considered singular (seeSquareMatrix.solve).
-
HarmonicFitter
public HarmonicFitter(EstimatedParameter[] coefficients, int maxIterations, double convergence, double steadyStateThreshold, double epsilon)
Deprecated. replaced byHarmonicFitter(EstimatedParameter[], Estimator)as of version 7.0Simple constructor.This constructor can be used when a first estimate of the coefficients is already known.
- Parameters:
coefficients- first estimate of the coefficients. A reference to this array is hold by the newly created object. Its elements will be adjusted during the fitting process and they will be set to the adjusted coefficients at the end.maxIterations- maximum number of iterations allowedconvergence- criterion threshold below which we do not need to improve the criterion anymoresteadyStateThreshold- steady state detection threshold, the problem has reached a steady state (read converged) ifMath.abs (Jn - Jn-1) < Jn * convergence, whereJnandJn-1are the current and preceding criterion value (square sum of the weighted residuals of considered measurements).epsilon- threshold under which the matrix of the linearized problem is considered singular (seeSquareMatrix.solve).
-
-
Method Detail
-
fit
public double[] fit() throws EstimationExceptionDescription copied from class:AbstractCurveFitterPerform the fitting.This method compute the coefficients of the curve that best fit the sample of weighted pairs previously given through calls to the
addWeightedPairmethod.- Overrides:
fitin classAbstractCurveFitter- Returns:
- coefficients of the curve
- Throws:
EstimationException- if the fitting is not possible (for example if the sample has to few independant points)
-
getAmplitude
public double getAmplitude()
Get the current amplitude coefficient estimate. Get a, wheref (t) = a cos (omega t + phi)- Returns:
- current amplitude coefficient estimate
-
getPulsation
public double getPulsation()
Get the current pulsation coefficient estimate. Get omega, wheref (t) = a cos (omega t + phi)- Returns:
- current pulsation coefficient estimate
-
getPhase
public double getPhase()
Get the current phase coefficient estimate. Get phi, wheref (t) = a cos (omega t + phi)- Returns:
- current phase coefficient estimate
-
valueAt
public double valueAt(double x)
Get the value of the function at x according to the current parameters value.- Specified by:
valueAtin classAbstractCurveFitter- Parameters:
x- abscissa at which the theoretical value is requested- Returns:
- theoretical value at x
-
partial
public double partial(double x, EstimatedParameter p)Get the derivative of the function at x with respect to parameter p.- Specified by:
partialin classAbstractCurveFitter- Parameters:
x- abscissa at which the partial derivative is requestedp- parameter with respect to which the derivative is requested- Returns:
- partial derivative
-
-
DataMelt 3.0 © DataMelt by jWork.ORG