FunctionBasis<T>.LeastSquaresFit Method

Definition

Namespace: Numerics.NET.Curves.Generic
Assembly: Numerics.NET.Generic (in Numerics.NET.Generic.dll) Version: 9.0.0

Overload List

LeastSquaresFit(Vector<T>, Vector<T>) Gets the least squares fit of target data in terms of the components of the FunctionBasis.
LeastSquaresFit(T[], T[], T[]) Gets the least squares fit of target data in terms of the components of the FunctionBasis.
LeastSquaresFit(T[], T[], Int32) Gets the least squares fit of target data in terms of the components of the FunctionBasis.
LeastSquaresFit(Vector<T>, Vector<T>, Vector<T>) Gets the least squares fit of target data in terms of the components of the FunctionBasis.

LeastSquaresFit(Vector<T>, Vector<T>)

Gets the least squares fit of target data in terms of the components of the FunctionBasis.
C#
public virtual LinearCombination<T> LeastSquaresFit(
	Vector<T> xValues,
	Vector<T> yValues
)

Parameters

xValues  Vector<T>
A vector containing the data points for the fit.
yValues  Vector<T>
A vector containing the data values corresponding to the data points in xValues.

Return Value

LinearCombination<T>
A LinearCombination that is the least squares fit of the data in terms of this FunctionBasis.

Exceptions

ArgumentNullExceptionxValues is null.

-or-

yValues is null.

[!:Mathematics.TotalLossOfPrecisionException] The solution of the least squares problem could not be found because roundoff error caused a total loss of precision.
DimensionMismatchExceptionThe xValues and yValues do not have the same length.
ArgumentException The number of data points is less than the number of basis functions.

LeastSquaresFit(T[], T[], T[])

Gets the least squares fit of target data in terms of the components of the FunctionBasis.
C#
public virtual LinearCombination<T> LeastSquaresFit(
	T[] xValues,
	T[] yValues,
	T[] weights
)

Parameters

xValues  T[]
A T array containing the data points for the fit.
yValues  T[]
A T array containing the data values corresponding to the data points. in xValues.
weights  T[]
A T array containing the weights to assign to the residual error corresponding to the data values in yValues.

Return Value

LinearCombination<T>
A LinearCombination that is the least squares fit of the data in terms of this FunctionBasis.

Exceptions

ArgumentNullExceptionxValues is null.

-or-

yValues is null.

TotalLossOfPrecisionException The solution of the least squares problem could not be found because roundoff error caused a total loss of precision.
DimensionMismatchExceptionThe xValues and yValues do not have the same length.
ArgumentException The number of data points is less than the number of basis functions.

LeastSquaresFit(T[], T[], Int32)

Gets the least squares fit of target data in terms of the components of the FunctionBasis.
C#
public virtual LinearCombination<T> LeastSquaresFit(
	T[] xValues,
	T[] yValues,
	int numberOfDataPoints
)

Parameters

xValues  T[]
An array containing the data points for the fit.
yValues  T[]
A array containing the data values corresponding to the data points in xValues.
numberOfDataPoints  Int32
The number of actual data points.

Return Value

LinearCombination<T>
A LinearCombination that is the least squares fit of the data in terms of this FunctionBasis.

Remarks

Use this method to calculate a LinearCombination of the basis functions in this instance through a set of points using the least squares method.

Only the first numberOfDataPoints values in xValues and yValues are used.

Exceptions

ArgumentNullExceptionxValues is null.

-or-

yValues is null.

ArgumentOutOfRangeExceptionnumberOfDataPoints is less than the number of basis functions.

-or-

numberOfDataPoints is greater than the length of xValues

-or-

numberOfDataPoints is greater than the length of yValues

TotalLossOfPrecisionException The solution of the least squares problem could not be found because roundoff error caused a total loss of precision.

LeastSquaresFit(Vector<T>, Vector<T>, Vector<T>)

Gets the least squares fit of target data in terms of the components of the FunctionBasis.
C#
public virtual LinearCombination<T> LeastSquaresFit(
	Vector<T> xValues,
	Vector<T> yValues,
	Vector<T>? weights
)

Parameters

xValues  Vector<T>
A vector containing the data points for the fit.
yValues  Vector<T>
A vector containing the data values corresponding to the data points in xValues.
weights  Vector<T>
A vector containing the weights to assign to the residual error corresponding to the data values in yValues.

Return Value

LinearCombination<T>
A LinearCombination that is the least squares fit of the data in terms of this FunctionBasis.

Exceptions

ArgumentNullExceptionxValues is null.

-or-

yValues is null.

[!:Mathematics.TotalLossOfPrecisionException] The solution of the least squares problem could not be found because roundoff error caused a total loss of precision.
DimensionMismatchExceptionThe xValues and yValues do not have the same length.
ArgumentException The number of data points is less than the number of basis functions.

See Also