org.spaceroots.mantissa.fitting
Class AbstractCurveFitter
- java.lang.Object
-
- org.spaceroots.mantissa.fitting.AbstractCurveFitter
-
- All Implemented Interfaces:
- java.io.Serializable, EstimationProblem
- Direct Known Subclasses:
- HarmonicFitter, PolynomialFitter
public abstract class AbstractCurveFitter extends java.lang.Object implements EstimationProblem, java.io.Serializable
This class is the base class for all curve fitting classes in the package.This class handles all common features of curve fitting like the sample points handling. It declares two methods (
valueAt(double)andpartial(double, org.spaceroots.mantissa.estimation.EstimatedParameter)) which should be implemented by sub-classes to define the precise shape of the curve they represent.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classAbstractCurveFitter.FitMeasurementThis class represents the fit measurements.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidaddWeightedPair(double weight, double x, double y)Add a weighted (x,y) pair to the sample.double[]fit()Perform the fitting.EstimatedParameter[]getAllParameters()Get all the parameters of the problem.WeightedMeasurement[]getMeasurements()Get the measurements of an estimation problem.EstimatedParameter[]getUnboundParameters()Get the unbound parameters of the problem.abstract doublepartial(double x, EstimatedParameter p)Get the derivative of the function at x with respect to parameter p.abstract doublevalueAt(double x)Get the value of the function at x according to the current parameters value.
-
-
-
Method Detail
-
addWeightedPair
public void addWeightedPair(double weight, double x, double y)Add a weighted (x,y) pair to the sample.- Parameters:
weight- weight of this pair in the fitx- abscissay- ordinate, we havey = f (x)
-
fit
public double[] fit() throws EstimationExceptionPerform 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.- Returns:
- coefficients of the curve
- Throws:
EstimationException- if the fitting is not possible (for example if the sample has to few independant points)
-
getMeasurements
public WeightedMeasurement[] getMeasurements()
Description copied from interface:EstimationProblemGet the measurements of an estimation problem.- Specified by:
getMeasurementsin interfaceEstimationProblem- Returns:
- measurements
-
getUnboundParameters
public EstimatedParameter[] getUnboundParameters()
Get the unbound parameters of the problem. For a curve fitting, none of the function coefficient is bound.- Specified by:
getUnboundParametersin interfaceEstimationProblem- Returns:
- unbound parameters
-
getAllParameters
public EstimatedParameter[] getAllParameters()
Get all the parameters of the problem.- Specified by:
getAllParametersin interfaceEstimationProblem- Returns:
- parameters
-
valueAt
public abstract double valueAt(double x)
Get the value of the function at x according to the current parameters value.- Parameters:
x- abscissa at which the theoretical value is requested- Returns:
- theoretical value at x
-
partial
public abstract double partial(double x, EstimatedParameter p)Get the derivative of the function at x with respect to parameter p.- 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