Class SvdSingleDimensionLinearFitter


public class SvdSingleDimensionLinearFitter extends SingleDimensionLinearFitter
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 Details

    • DEFAULT_TOL

      public static final double DEFAULT_TOL
      Default tolerance.
      See Also:
    • tol

      private double tol
      Tolerance 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

      public void fit() throws FittingException, NotReadyException
      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 class Fitter
      Throws:
      FittingException - if fitting fails.
      NotReadyException - if enough input data has not yet been provided.