Class SimpleSingleDimensionLinearFitter


public class SimpleSingleDimensionLinearFitter 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 class is based on the implementation available at Numerical Recipes 3rd Ed, page 791
  • Field Details

    • ia

      private boolean[] ia
      Determines 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 class SingleDimensionLinearFitter
      Parameters:
      evaluator - function evaluator.
      Throws:
      FittingException - if evaluation fails.
    • 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.
    • 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.