Skip to main content

linregress_py

Function linregress_py 

Source
pub fn linregress_py(
    py: Python<'_>,
    x: &Bound<'_, PyArray1<f64>>,
    y: &Bound<'_, PyArray1<f64>>,
) -> PyResult<Py<PyAny>>
Expand description

Calculate a simple linear regression on two 1D arrays.

Performs ordinary least squares (OLS) linear regression to fit a line y = slope * x + intercept to the data, and computes the correlation coefficient, p-value, and standard error of the slope.

Parameters: x: Independent variable (predictor) y: Dependent variable (response) Must be same length as x

Returns: Dictionary with: - slope: Slope of the regression line - intercept: Y-intercept of the regression line - rvalue: Correlation coefficient (Pearson’s r) - pvalue: Two-sided p-value for testing H₀: slope = 0 - stderr: Standard error of the slope estimate