How to use this calculator
Estimate a line using the median of all finite pairwise slopes and a joint residual-median intercept.
- Enter Predictor values, Response values. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Theil Sen robust line estimate explained
The Theil–Sen line uses the median slope across all nonvertical observation pairs, then the median of y−mx for its intercept. The result is less driven by individual extreme points than a least-squares line, but this page does not calculate an interval.
Inputs, symbols, and units
x— Predictor values- Predictor values. Use comma-separated values in the stated order.
y— Response values- Response values. Use comma-separated values in the stated order.
Formula and method
m = median[(yⱼ−yᵢ)/(xⱼ−xᵢ)] over i Duplicate-x pairs do not define finite slopes, and at most 300 observations are accepted.
A worked scenario
Predictor values = 1, 2, 3, 4; Response values = 1, 2, 2, 5.
- Theil–Sen slope: 1.16666667
- Joint median intercept: -0.25 y units
For points (1,1), (2,2), (3,2), and (4,5), the median of the six pairwise slopes is 7/6. The median residual y−(7/6)x is −0.25.
Assumptions and edge cases
At most 300 pairs of observations; duplicate x pairs are skipped. No confidence interval is computed.
Frequently asked questions
Are vertical pairs used?
No, equal x values do not define a finite slope.
How is the intercept chosen?
Median of y−slope×x, the joint convention.
Is this identical to least squares?
No, it uses medians rather than minimizing squared residuals.
How do I use the Theil Sen robust line estimate calculator?
Enter Predictor values, Response values. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Theil Sen robust line estimate?
Predictor values = 1, 2, 3, 4; Response values = 1, 2, 2, 5. Theil–Sen slope: 1.16666667 Joint median intercept: -0.25 y units For points (1,1), (2,2), (3,2), and (4,5), the median of the six pairwise slopes is 7/6. The median residual y−(7/6)x is −0.25.
Method reference: SciPy theilslopes definition.
Read our calculation methodology.