Click or drag to resize

Bivariate.LinearRegression Method

Computes the best-fit linear regression from the data.

Namespace:  Meta.Numerics.Statistics
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: 4.1.4
Syntax
public static LinearRegressionResult LinearRegression(
	this IReadOnlyList<double> y,
	IReadOnlyList<double> x
)

Parameters

y
Type: System.Collections.Generic.IReadOnlyList<Double>
The values of the dependent variables (y-coordinates).
x
Type: System.Collections.Generic.IReadOnlyList<Double>
The values of the independent variable (x-coordinates).

Return Value

Type: 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 IReadOnlyList<Double>. 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).
Exceptions
ExceptionCondition
ArgumentNullExceptionx or y is null.
DimensionMismatchExceptionx and y do not contain the same number of entries.
InsufficientDataExceptionThere are fewer than three data points.
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.

See Also