Class LeastSquaresFit.Linear

All Implemented Interfaces:
DoubleUnaryOperator, RealValuedDomainOps, RealValuedFunctOps, RealValuedFunctVAOps, VADomainOps
Direct Known Subclasses:
LeastSquaresFit.FunctionBasis, LeastSquaresFit.Polynomial
Enclosing class:
LeastSquaresFit

public abstract static class LeastSquaresFit.Linear extends LeastSquaresFit
Class for linear least-squares fit.

For a description of the algorithms used, see P. H. Richter, "Estimating Errors in Least-Squares Fitting", TDA Progress Report 42-122, JPL, 1995.

Given a set of functions $X_j$ and corefficients $a_j$, a linear least squares fit fits a function $y(x; a) = \sum_j a_jX_j(x)$ to a set of values yi corresponding to a value of x given by xi. The function y(x;a) is a linear function of the parameters a but not necessarily of the variable x. Each value yi is a random variable with a standard deviation given by σi.

  • Constructor Details

    • Linear

      public Linear()
  • Method Details

    • setVariance

      protected void setVariance(double value)
      Set the variance. The variance should be set to zero in cases where the covariance matrix should be set to zero. Otherwise, it should be set to a variance by which the computed covariances will be multiplied. This is intended for cases where the covariance is computed as if sigma had the value of 1.0 (some subclasses do this when all the values of sigma are the same).
      Parameters:
      value - the value of the variance, which must not be negative.
    • setDecomp

      protected void setDecomp(double[][] H)
      Set the TriangularDecomp object for this least squares fit by providing the matrix to decompose. This is used to obtain the variance. The description in the reference P. H. Richter, "Estimating Errors in Least-Squares Fitting", TDA Progress Report 42-122, JPL, 1995, page 116 defines a matrix H = ≡ ATA, where Aij = Xiji and Xij is the value of the basis function indexed by j for the data point indexed by i. This method stores the matrix H (by reference) and will create an instance of CholeskyDecomp when needed to compute the inverse of H when needed (the inverse of H is the covariance matrix).
      Parameters:
      H - the matrix to decompose
    • setDecomp

      protected void setDecomp(TriangularDecomp value)
      Set the TriangularDecomp object for this least squares fit. This is used to obtain the variance. The description in the reference P. H. Richter, "Estimating Errors in Least-Squares Fitting", TDA Progress Report 42-122, JPL, 1995, page 116 defines a matrix H = ≡ ATA, where Aij = Xiji and Xij is the value of the basis function indexed by j for the data point indexed by i. The caller will call the constructor of one of TriangularDecomp's subclasses using H as its argument. Of the existing choices, CholeskyDecomp is the preferred one to use. The classes the BZDev library provides have constructors that take one or two arguments: for example, new CholeskyDecomp(H) or new CholeskyDecomp(H,H) (the later if H is not further used). One a TriangularDecomp object is created, one then calls this method to make the CholeskyDecomp object available to this class: H is the inverse of the covariance matrix.
      Parameters:
      value - the TriangularDecomp instance to use
    • getDecomp

      protected TriangularDecomp getDecomp()
      Get the TriangularDecomp object for this least squares fit.
      Returns:
      the trianbular decomposition
    • createCovariance

      protected void createCovariance()
      Description copied from class: LeastSquaresFit
      Create the covariance array. Subclasses must implement this method, which is expected to set up the covariance array and then call LeastSquaresFit.setCovariance(double[][]) to make it available.
      Specified by:
      createCovariance in class LeastSquaresFit