Function linreg::linear_regression[][src]

pub fn linear_regression<X, Y, F>(xs: &[X], ys: &[Y]) -> Option<(F, F)> where
    X: Clone + Into<F>,
    Y: Clone + Into<F>,
    F: Float

Linear regression from two slices

Calculates the linear regression from two slices, one for x- and one for y-values.

Returns None if

  • xs and ys differ in length
  • xs or ys do not have a mean (e.g. if they are empty, see IteratorMean for details)
  • the slope is too steep to represent, approaching infinity

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