ChebyshevSeries.LeastSquaresFit Method

Definition

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

Overload List

LeastSquaresFit(Vector<Double>, Vector<Double>, Int32) Returns the Polynomial that is the best least squares fit through the given set of points.
LeastSquaresFit(Vector<Double>, Vector<Double>, Double, Double, Int32) Returns the Polynomial that is the best least squares fit through the given set of points.

LeastSquaresFit(Vector<Double>, Vector<Double>, Int32)

Returns the Polynomial that is the best least squares fit through the given set of points.
C#
public static ChebyshevSeries LeastSquaresFit(
	Vector<double> xValues,
	Vector<double> yValues,
	int degree
)

Parameters

xValues  Vector<Double>
A vector containing the X-coordinates of the points.
yValues  Vector<Double>
A vector containing the Y-coordinates of the points.
degree  Int32
The degree of the least squares polynomial. Must be smaller than the number of data points.

Return Value

ChebyshevSeries
A ChebyshevSeries that is the least squares fit through the given set of points.

Remarks

The least squares fit of a polynomial through a set of points is the polynomial that minimizes the sum of the squares of the residuals. The residuals are the differences between the predicted and the actual values.

The coordinates of the points are provided in two Double arrays. These must have the same number of elements, or an exception is thrown.

In rare cases, the least squares polynomial is a vertical line. In this case, a DivideByZeroException exception is thrown.

Exceptions

ArgumentNullException

xValues is null.

-or-

yValues is null.

ArgumentOutOfRangeException

degree is less than zero or greater than or equal to the number of data points.

DimensionMismatchException

The arrays xValues and yValues have different lengths.

LeastSquaresFit(Vector<Double>, Vector<Double>, Double, Double, Int32)

Returns the Polynomial that is the best least squares fit through the given set of points.
C#
public static ChebyshevSeries LeastSquaresFit(
	Vector<double> xValues,
	Vector<double> yValues,
	double lowerBound,
	double upperBound,
	int degree
)

Parameters

xValues  Vector<Double>
A vector containing the X-coordinates of the points.
yValues  Vector<Double>
A vector containing the Y-coordinates of the points.
lowerBound  Double
The lower bound of the interval.
upperBound  Double
The upper bound of the interval.
degree  Int32
The degree of the least squares polynomial. Must be smaller than the number of data points.

Return Value

ChebyshevSeries
A ChebyshevSeries that is the least squares fit through the given set of points.

Remarks

The least squares fit of a polynomial through a set of points is the polynomial that minimizes the sum of the squares of the residuals. The residuals are the differences between the predicted and the actual values.

The coordinates of the points are provided in two Double arrays. These must have the same number of elements, or an exception is thrown.

In rare cases, the least squares polynomial is a vertical line. In this case, a DivideByZeroException exception is thrown.

Exceptions

ArgumentNullException

xValues is null.

-or-

yValues is null.

ArgumentOutOfRangeException

degree is less than zero or greater than or equal to the number of data points.

DimensionMismatchException

The arrays xValues and yValues have different lengths.

See Also