public abstract class AbstractCurveFitter extends java.lang.Object implements EstimationProblem, java.io.Serializable
This class handles all common features of curve fitting like the
sample points handling. It declares two methods (valueAt(double) and partial(double, org.spaceroots.mantissa.estimation.EstimatedParameter)) which should be implemented by
sub-classes to define the precise shape of the curve they
represent.
| Modifier and Type | Class and Description |
|---|---|
class |
AbstractCurveFitter.FitMeasurement
This class represents the fit measurements.
|
| Modifier and Type | Field and Description |
|---|---|
protected EstimatedParameter[] |
coefficients
Coefficients of the function
|
protected java.util.List |
measurements
Measurements vector
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCurveFitter(EstimatedParameter[] coefficients,
Estimator estimator)
Simple constructor.
|
protected |
AbstractCurveFitter(int n,
Estimator estimator)
Simple constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWeightedPair(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 double |
partial(double x,
EstimatedParameter p)
Get the derivative of the function at x with respect to parameter p.
|
protected void |
sortMeasurements()
Utility method to sort the measurements with respect to the abscissa.
|
abstract double |
valueAt(double x)
Get the value of the function at x according to the current parameters value.
|
protected EstimatedParameter[] coefficients
protected java.util.List measurements
protected AbstractCurveFitter(int n,
Estimator estimator)
n - number of coefficients in the underlying functionestimator - estimator to use for the fittingprotected AbstractCurveFitter(EstimatedParameter[] coefficients, Estimator estimator)
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 fittingpublic void addWeightedPair(double weight,
double x,
double y)
weight - weight of this pair in the fitx - abscissay - ordinate, we have y = f (x)public double[] fit()
throws EstimationException
This method compute the coefficients of the curve that best
fit the sample of weighted pairs previously given through calls
to the addWeightedPair method.
EstimationException - if the fitting is not possible
(for example if the sample has to few independant points)public WeightedMeasurement[] getMeasurements()
EstimationProblemgetMeasurements in interface EstimationProblempublic EstimatedParameter[] getUnboundParameters()
getUnboundParameters in interface EstimationProblempublic EstimatedParameter[] getAllParameters()
getAllParameters in interface EstimationProblemprotected void sortMeasurements()
This method is provided as a utility for derived classes. As
an example, the HarmonicFitter class needs it in order to
compute a first guess of the coefficients to initialize the
estimation algorithm.
public abstract double valueAt(double x)
x - abscissa at which the theoretical value is requestedpublic abstract double partial(double x,
EstimatedParameter p)
x - abscissa at which the partial derivative is requestedp - parameter with respect to which the derivative is requestedCopyright © 2001-2007 Luc Maisonobe. All Rights Reserved.