Package com.irurueta.numerical.fitting
Class SvdSingleDimensionLinearFitter
java.lang.Object
com.irurueta.numerical.fitting.Fitter
com.irurueta.numerical.fitting.SingleDimensionFitter
com.irurueta.numerical.fitting.SingleDimensionLinearFitter
com.irurueta.numerical.fitting.SvdSingleDimensionLinearFitter
Fits provided data (x,y) to a function made of a linear combination of
functions used as a basis (i.e. f(x) = a * f0(x) + b * f1(x) + ...).
Where f0, f1, ... is the function basis which ideally should be formed by
orthogonal function.
This is an improvement on SimpleLinearFitter for cases where basis functions
cannot be clearly distinguished from provided data, to avoid matrix
singularities and obtain better results.
This class is based on the implementation available at Numerical Recipes
3rd Ed, page 795.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
Default tolerance.private double
Tolerance to define convergence threshold for SVD.Fields inherited from class com.irurueta.numerical.fitting.SingleDimensionLinearFitter
afunc, evaluator, ma
Fields inherited from class com.irurueta.numerical.fitting.SingleDimensionFitter
a, chisq, covar, ndat, sig, x, y
Fields inherited from class com.irurueta.numerical.fitting.Fitter
resultAvailable
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.SvdSingleDimensionLinearFitter
(double[] x, double[] y, double sig) Constructor.SvdSingleDimensionLinearFitter
(double[] x, double[] y, double[] sig) Constructor.Constructor.SvdSingleDimensionLinearFitter
(LinearFitterSingleDimensionFunctionEvaluator evaluator, double[] x, double[] y, double sig) Constructor.SvdSingleDimensionLinearFitter
(LinearFitterSingleDimensionFunctionEvaluator evaluator, double[] x, double[] y, double[] sig) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fit()
Fits a function to provided data so that parameters associated to that function can be estimated along with their covariance matrix and chi square value.double
getTol()
Returns tolerance to define convergence threshold for SVD.void
setTol
(double tol) Sets tolerance to define convergence threshold for SVD.Methods inherited from class com.irurueta.numerical.fitting.SingleDimensionLinearFitter
getFunctionEvaluator, isReady, setFunctionEvaluator
Methods inherited from class com.irurueta.numerical.fitting.SingleDimensionFitter
getA, getChisq, getCovar, getSig, getX, getY, setInputData, setInputData
Methods inherited from class com.irurueta.numerical.fitting.Fitter
isResultAvailable
-
Field Details
-
DEFAULT_TOL
public static final double DEFAULT_TOLDefault tolerance.- See Also:
-
tol
private double tolTolerance to define convergence threshold for SVD.
-
-
Constructor Details
-
SvdSingleDimensionLinearFitter
public SvdSingleDimensionLinearFitter()Constructor. -
SvdSingleDimensionLinearFitter
public SvdSingleDimensionLinearFitter(double[] x, double[] y, double[] sig) Constructor.- Parameters:
x
- input points x where a linear single dimensional function f(x) = a * f0(x) + b * f1(x) + ...y
- result of evaluation of linear single dimensional function f(x) at provided x points.sig
- standard deviations of each pair of points (x, y).- Throws:
IllegalArgumentException
- if provided arrays don't have the same length.
-
SvdSingleDimensionLinearFitter
public SvdSingleDimensionLinearFitter(double[] x, double[] y, double sig) Constructor.- Parameters:
x
- input points x where a linear single dimensional function f(x) = a * f0(x) + b * f1(x) + ...y
- result of evaluation of linear single dimensional function f(x) at provided x points.sig
- standard deviation of all pair of points assuming that standard deviations are constant.- Throws:
IllegalArgumentException
- if provided arrays don't have the same length.
-
SvdSingleDimensionLinearFitter
public SvdSingleDimensionLinearFitter(LinearFitterSingleDimensionFunctionEvaluator evaluator) throws FittingException Constructor.- Parameters:
evaluator
- evaluator to evaluate function at provided point and obtain the evaluation of function basis at such point.- Throws:
FittingException
- if evaluation fails.
-
SvdSingleDimensionLinearFitter
public SvdSingleDimensionLinearFitter(LinearFitterSingleDimensionFunctionEvaluator evaluator, double[] x, double[] y, double[] sig) throws FittingException Constructor.- Parameters:
evaluator
- evaluator to evaluate function at provided point and obtain the evaluation of function basis at such point.x
- input points x where a linear single dimensional function f(x) = a * f0(x) + b * f1(x) + ...y
- result of evaluation of linear single dimensional function f(x) at provided x points.sig
- standard deviation of all pair of points assuming that standard deviations are constant.- Throws:
FittingException
- if evaluation fails.IllegalArgumentException
- if provided arrays don't have the same length.
-
SvdSingleDimensionLinearFitter
public SvdSingleDimensionLinearFitter(LinearFitterSingleDimensionFunctionEvaluator evaluator, double[] x, double[] y, double sig) throws FittingException Constructor.- Parameters:
evaluator
- evaluator to evaluate function at provided point and obtain the evaluation of function basis at such point.x
- input points x where a linear single dimensional function f(x) = a * f0(x) + b * f1(x) + ...y
- result of evaluation of linear single dimensional function f(x) at provided x points.sig
- standard deviation of all pair of points assuming that standard deviations are constant.- Throws:
FittingException
- if evaluation fails.IllegalArgumentException
- if provided arrays don't have the same length.
-
-
Method Details
-
getTol
public double getTol()Returns tolerance to define convergence threshold for SVD.- Returns:
- tolerance to define convergence threshold for SVD.
-
setTol
public void setTol(double tol) Sets tolerance to define convergence threshold for SVD.- Parameters:
tol
- tolerance to define convergence threshold for SVD.
-
fit
Fits a function to provided data so that parameters associated to that function can be estimated along with their covariance matrix and chi square value.- Specified by:
fit
in classFitter
- Throws:
FittingException
- if fitting fails.NotReadyException
- if enough input data has not yet been provided.
-