java.lang.Object
org.bzdev.math.RealValuedFunctionVA
org.bzdev.math.RealValuedFunction
org.bzdev.math.LeastSquaresFit
org.bzdev.math.LeastSquaresFit.Linear
org.bzdev.math.LeastSquaresFit.FunctionBasis
- All Implemented Interfaces:
DoubleUnaryOperator,RealValuedDomainOps,RealValuedFunctOps,RealValuedFunctVAOps,VADomainOps
- Enclosing class:
- LeastSquaresFit
Linear least squares fit using a specified function basis.
The parameters are provided in an array with an ordering matching
that of the basis functions passed as the variable-length argument
for this class' constructors.
- See Also:
-
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
ConstructorsConstructorDescriptionFunctionBasis(double[] x, double[] y, double[] sigma, RealValuedFunctionVA.Linear f) Constructor given the standard deviations for the Y values and a real-valued function that is a linear combination of basis functions.FunctionBasis(double[] x, double[] y, double[] sigma, T... fs) Constructor given the standard deviations for the Y values.FunctionBasis(double[] x, double[] y, double sigma, RealValuedFunctionVA.Linear f) Constructor given the standard deviation for the Y values and a real-valued function that is a linear combination of basis functions.FunctionBasis(double[] x, double[] y, double sigma, T... fs) Constructor given the standard deviation for the Y values.FunctionBasis(double[] x, double[] y, RealValuedFunctionVA.Linear f) Constructor given a real-valued function that is a linear combination of basis functions.FunctionBasis(double[] x, double[] y, T... fs) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondoublecovariance(double x1, double x2) Compute the covariance for the y values associated with two data points.doublederivAt(double arg) Evaluate the function's first derivative.protected LeastSquaresFitgetFit()Get a copy of this least squares fit but without its parameters, degrees of freedom, chi square value, reduced chi square value, or covariance set.doublesecondDerivAt(double arg) Evaluate the function's second derivative.doublevalueAt(double arg) Call the function.Methods inherited from class org.bzdev.math.LeastSquaresFit.Linear
createCovariance, getDecomp, setDecomp, setDecomp, setVarianceMethods inherited from class org.bzdev.math.LeastSquaresFit
chiSquare, chiSquare, getChiSquare, getCovarianceArray, getCovarianceMatrix, getCovarianceMatrix, getDegreesOfFreedom, getFunction, getNumberOfParameters, getParameters, getParameters, getParametersArray, getReducedChiSquare, getStat, setChiSquare, setCovariance, setDegreesOfFreedom, setParameters, setReducedChiSquare, sumOfSquaresMethods inherited from class org.bzdev.math.RealValuedFunction
deriv, deriv, derivAt, domainMaxClosed, domainMaxClosed, domainMinClosed, domainMinClosed, getDomainMax, getDomainMax, getDomainMin, getDomainMin, isInDomain, isInDomain, secondDeriv, secondDerivAt, valueAtMethods inherited from class org.bzdev.math.RealValuedFunctionVA
jacobian, jacobian, maxArgLength, minArgLengthMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bzdev.math.RealValuedFunctOps
andThen, andThen, applyAsDouble, compose, compose, maxArgLength, minArgLength
-
Constructor Details
-
FunctionBasis
Constructor. The number of basis functions determines the number of parameters. IfRealValuedFunction.derivAt(double)orRealValuedFunction.secondDerivAt(double)are used, the basis functions must implement the corresponding derivatives.- Type Parameters:
T- a type that implements or extends RealValuedFunctionops- Parameters:
y- the values for yix- the values for xifs- the basis functions- Throws:
IllegalArgumentException- an argument was null
-
FunctionBasis
Constructor given a real-valued function that is a linear combination of basis functions. The number of basis functions determines the number of parameters. IfRealValuedFunction.derivAt(double)orRealValuedFunction.secondDerivAt(double)are used, the basis functions used by f must implement the corresponding derivatives.- Parameters:
x- the values for xiy- the values for yif- a real-valued function with multiple arguments
-
FunctionBasis
Constructor given the standard deviation for the Y values. The number of basis functions determines the number of parameters. IfRealValuedFunction.derivAt(double)orRealValuedFunction.secondDerivAt(double)are used, the basis functions must implement the corresponding derivatives.- Type Parameters:
T- a subtype ofRealValuedFunctOps- Parameters:
x- the values for xiy- the values for yisigma- the standard deviation for every y valuefs- the basis functions
-
FunctionBasis
Constructor given the standard deviation for the Y values and a real-valued function that is a linear combination of basis functions. The number of basis functions determines the number of parameters. IfRealValuedFunction.derivAt(double)orRealValuedFunction.secondDerivAt(double)are used, the basis functions used by f must implement the corresponding derivatives.- Parameters:
x- the values for xiy- the values for yisigma- the standard deviation for every y valuef- a real-valued function with multiple arguments
-
FunctionBasis
Constructor given the standard deviations for the Y values. The number of basis functions determines the number of parameters. IfRealValuedFunction.derivAt(double)orRealValuedFunction.secondDerivAt(double)are used, the basis functions must implement the corresponding derivatives.- Type Parameters:
T- the type of the functions- Parameters:
x- the values for xiy- the values for yisigma- the standard deviations σi for the corresponding Y value yifs- the basis functions
-
FunctionBasis
Constructor given the standard deviations for the Y values and a real-valued function that is a linear combination of basis functions. The number of basis functions determines the number of parameters. IfRealValuedFunction.derivAt(double)orRealValuedFunction.secondDerivAt(double)are used, the basis functions used by f must implement the corresponding derivatives.- Parameters:
x- the values for xiy- the values for yisigma- the standard deviations σi for the corresponding Y value yif- a real-valued function with multiple arguments
-
-
Method Details
-
getFit
Description copied from class:LeastSquaresFitGet a copy of this least squares fit but without its parameters, degrees of freedom, chi square value, reduced chi square value, or covariance set.This method is used by
LeastSquaresFit.getFunction(double[]), which only provides a real-valued function. The only methods that will be called on the value returned areLeastSquaresFit.setChiSquare(double),LeastSquaresFit.setDegreesOfFreedom(int),LeastSquaresFit.setReducedChiSquare(double),LeastSquaresFit.setParameters(double[]),RealValuedFunction.valueAt(double),RealValuedFunction.derivAt(double), andRealValuedFunction.secondDerivAt(double).- Specified by:
getFitin classLeastSquaresFit- Returns:
- a least squares fit
-
covariance
public double covariance(double x1, double x2) Description copied from class:LeastSquaresFitCompute the covariance for the y values associated with two data points. The covariance for two random variables X and Y is E[(X-E[X](Y-E[Y])] where E[Z] is the expected value of a random variable Z. The covariance of X and X is simply the variance of X. The value returned allows one to estimate the error in the fit at any point, not just the data points, and whether errors at different values of X are correlated.- Specified by:
covariancein classLeastSquaresFit- Parameters:
x1- the x value for the first y valuex2- the x value for the second y value- Returns:
- the covariance
-
valueAt
public double valueAt(double arg) Description copied from class:RealValuedFunctionCall the function.- Specified by:
valueAtin interfaceRealValuedFunctOps- Overrides:
valueAtin classRealValuedFunction- Parameters:
arg- the function's argument- Returns:
- the value of the function for the given argument
-
derivAt
Description copied from class:RealValuedFunctionEvaluate the function's first derivative.- Overrides:
derivAtin classRealValuedFunction- Parameters:
arg- the function's argument- Returns:
- the value of the function for the given argument
- Throws:
UnsupportedOperationException- the operation is not supported.
-
secondDerivAt
Description copied from class:RealValuedFunctionEvaluate the function's second derivative.- Overrides:
secondDerivAtin classRealValuedFunction- Parameters:
arg- the function's argument- Returns:
- the value of the function for the given argument
- Throws:
UnsupportedOperationException- the operation is not supported.
-