Skip to main content

linear_regression

Function linear_regression 

Source
pub fn linear_regression(x: &[f64], y: &[f64]) -> (f64, f64, f64)
Expand description

Simple ordinary least-squares linear regression.

Fits the model y = slope * x + intercept and returns (slope, intercept, r_squared). Returns (0.0, 0.0, 0.0) for fewer than 2 points.