Package com.irurueta.numerical.fitting
Class SimpleSingleDimensionLinearFitter
java.lang.Object
com.irurueta.numerical.fitting.Fitter
com.irurueta.numerical.fitting.SingleDimensionFitter
com.irurueta.numerical.fitting.SingleDimensionLinearFitter
com.irurueta.numerical.fitting.SimpleSingleDimensionLinearFitter
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 class is based on the implementation available at Numerical Recipes
3rd Ed, page 791
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean[]
Determines which parameters can be modified during estimation (if true) and which ones are locked (if false)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.SimpleSingleDimensionLinearFitter
(double[] x, double[] y, double sig) Constructor.SimpleSingleDimensionLinearFitter
(double[] x, double[] y, double[] sig) Constructor.Constructor.SimpleSingleDimensionLinearFitter
(LinearFitterSingleDimensionFunctionEvaluator evaluator, double[] x, double[] y, double sig) Constructor.SimpleSingleDimensionLinearFitter
(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.void
free
(int i) Releases parameter at position i of linear combination of basis functions, so it can be modified again if needed.void
hold
(int i, double val) Prevents parameter at position i of linear combination of basis functions to be modified during function fitting.final void
Sets function evaluator to evaluate function at a given point and obtain the evaluation of function basis at such point.private static void
swap
(double[] array1, double[] array2, int pos1, int pos2) Swaps values of arrays at provided positions.Methods inherited from class com.irurueta.numerical.fitting.SingleDimensionLinearFitter
getFunctionEvaluator, isReady
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
-
ia
private boolean[] iaDetermines which parameters can be modified during estimation (if true) and which ones are locked (if false)
-
-
Constructor Details
-
SimpleSingleDimensionLinearFitter
public SimpleSingleDimensionLinearFitter()Constructor. -
SimpleSingleDimensionLinearFitter
public SimpleSingleDimensionLinearFitter(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.
-
SimpleSingleDimensionLinearFitter
public SimpleSingleDimensionLinearFitter(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.
-
SimpleSingleDimensionLinearFitter
public SimpleSingleDimensionLinearFitter(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.
-
SimpleSingleDimensionLinearFitter
public SimpleSingleDimensionLinearFitter(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 .
-
SimpleSingleDimensionLinearFitter
public SimpleSingleDimensionLinearFitter(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
-
setFunctionEvaluator
public final void setFunctionEvaluator(LinearFitterSingleDimensionFunctionEvaluator evaluator) throws FittingException Sets function evaluator to evaluate function at a given point and obtain the evaluation of function basis at such point.- Overrides:
setFunctionEvaluator
in classSingleDimensionLinearFitter
- Parameters:
evaluator
- function evaluator.- Throws:
FittingException
- if evaluation fails.
-
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.
-
hold
public void hold(int i, double val) Prevents parameter at position i of linear combination of basis functions to be modified during function fitting.- Parameters:
i
- position of parameter to be retained.val
- value to be set for parameter at position i.
-
free
public void free(int i) Releases parameter at position i of linear combination of basis functions, so it can be modified again if needed.- Parameters:
i
- position of parameter to be released.
-
swap
private static void swap(double[] array1, double[] array2, int pos1, int pos2) Swaps values of arrays at provided positions.- Parameters:
array1
- 1st array.array2
- 2nd array.pos1
- 1st position.pos2
- 2nd position.
-