[][src]Function linreg::linear_regression_of

pub fn linear_regression_of<X, Y, F>(xys: &[(X, Y)]) -> Result<(F, F), Error> where
    X: Clone + Into<F>,
    Y: Clone + Into<F>,
    F: FloatCore

Two-pass linear regression from tuples.

Calculates the linear regression from a slice of tuple values by first calculating the mean before calling lin_reg.

Returns Ok(slope, intercept) of the regression line.

Errors

Returns an error if

  • xys is empty
  • the slope is too steep to represent, approaching infinity
  • the number of elements cannot be represented as an F