scipy.stats.mstats.theilslopes

scipy.stats.mstats.theilslopes(y, x=None, alpha=0.95)[source]

Computes the Theil-Sen estimator for a set of points (x, y).

theilslopes implements a method for robust linear regression. It computes the slope as the median of all slopes between paired values.

Parameters:

y : array_like

Dependent variable.

x : array_like or None, optional

Independent variable. If None, use arange(len(y)) instead.

alpha : float, optional

Confidence degree between 0 and 1. Default is 95% confidence. Note that alpha is symmetric around 0.5, i.e. both 0.1 and 0.9 are interpreted as “find the 90% confidence interval”.

Returns:

medslope : float

Theil slope.

medintercept : float

Intercept of the Theil line, as median(y) - medslope*median(x).

lo_slope : float

Lower bound of the confidence interval on medslope.

up_slope : float

Upper bound of the confidence interval on medslope.

Notes

For more details on theilslopes, see stats.theilslopes.