BivariateLinearRegression Method

Computes the best-fit linear regression from the data.

Definition

Namespace: Meta.Numerics.Statistics
Assembly: Meta.Numerics (in Meta.Numerics.dll) Version: 4.2.0+6d77d64445f7d5d91b12e331399c4362ecb25333
C#
public static LinearRegressionResult LinearRegression(
	this IReadOnlyList<double> y,
	IReadOnlyList<double> x
)

Parameters

y  IReadOnlyListDouble
The values of the dependent variables (y-coordinates).
x  IReadOnlyListDouble
The values of the independent variable (x-coordinates).

Return Value

LinearRegressionResult
The result of the fit.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IReadOnlyListDouble. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Linear regression assumes that the data have been generated by a function y = a + b x + e, where e is normally distributed noise, and determines the values of a and b that best fit the data. It also determines a covariance matrix on the parameters a and b, and computes an ANOVA analysis of the fit.

Exceptions

ArgumentNullExceptionx or y is .
DimensionMismatchExceptionx and y do not contain the same number of entries.
InsufficientDataExceptionThere are fewer than three data points.

See Also