Function linreg::lin_reg[][src]

pub fn lin_reg<'a, X, Y, IX, IY, F>(
    xs: IX,
    ys: IY,
    x_mean: F,
    y_mean: F
) -> Option<(F, F)> where
    X: 'a + Into<F> + Clone,
    Y: 'a + Into<F> + Clone,
    IX: Iterator<Item = &'a X>,
    IY: Iterator<Item = &'a Y>,
    F: Float

Calculates a linear regression

Lower-level linear regression function. Assumes that x_mean and y_mean have already been calculated. Returns None if

  • the slope is too steep to represent, approaching infinity

Since there is a mean, this function assumes that xs and ys are both non-empty.

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