java.lang.Object
org.bzdev.math.RealValuedFunctionVA
org.bzdev.math.RealValuedFunction
org.bzdev.math.LeastSquaresFit
org.bzdev.math.LeastSquaresFit.Linear
- All Implemented Interfaces:
DoubleUnaryOperator
,RealValuedDomainOps
,RealValuedFunctOps
,RealValuedFunctVAOps
,VADomainOps
- Direct Known Subclasses:
LeastSquaresFit.FunctionBasis
,LeastSquaresFit.Polynomial
- Enclosing class:
- 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.math.LeastSquaresFit
LeastSquaresFit.BSpline, LeastSquaresFit.FunctionBasis, LeastSquaresFit.Linear, LeastSquaresFit.NonLinear, LeastSquaresFit.Polynomial
-
Field Summary
Fields inherited from class org.bzdev.math.RealValuedFunction
xFunction
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Create the covariance array.protected TriangularDecomp
Get the TriangularDecomp object for this least squares fit.protected void
setDecomp
(double[][] H) Set the TriangularDecomp object for this least squares fit by providing the matrix to decompose.protected void
setDecomp
(TriangularDecomp value) Set the TriangularDecomp object for this least squares fit.protected void
setVariance
(double value) Set the variance.Methods inherited from class org.bzdev.math.LeastSquaresFit
chiSquare, chiSquare, covariance, getChiSquare, getCovarianceArray, getCovarianceMatrix, getCovarianceMatrix, getDegreesOfFreedom, getFit, getFunction, getNumberOfParameters, getParameters, getParameters, getParametersArray, getReducedChiSquare, getStat, setChiSquare, setCovariance, setDegreesOfFreedom, setParameters, setReducedChiSquare, sumOfSquares
Methods inherited from class org.bzdev.math.RealValuedFunction
deriv, deriv, derivAt, derivAt, domainMaxClosed, domainMaxClosed, domainMinClosed, domainMinClosed, getDomainMax, getDomainMax, getDomainMin, getDomainMin, isInDomain, isInDomain, secondDeriv, secondDerivAt, secondDerivAt, valueAt, valueAt
Methods inherited from class org.bzdev.math.RealValuedFunctionVA
jacobian, jacobian, maxArgLength, minArgLength
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.math.RealValuedFunctOps
andThen, andThen, applyAsDouble, compose, compose, maxArgLength, minArgLength
-
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 = Xij/σi 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
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 = Xij/σi 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)
ornew 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
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 callLeastSquaresFit.setCovariance(double[][])
to make it available.- Specified by:
createCovariance
in classLeastSquaresFit
-