[−][src]Function linreg::linear_regression
pub fn linear_regression<X, Y, F>(xs: &[X], ys: &[Y]) -> Result<(F, F), Error> where
X: Clone + Into<F>,
Y: Clone + Into<F>,
F: FloatCore + Sum,
Two-pass simple linear regression from slices.
Calculates the linear regression from two slices, one for x- and one for y-values, by
calculating the mean and then calling lin_reg
.
Returns Ok(slope, intercept)
of the regression line.
Errors
Returns an error if
xs
andys
differ in lengthxs
orys
are empty- the slope is too steep to represent, approaching infinity
- the number of elements cannot be represented as an
F