File Exchange

image thumbnail

Theil-Sen Robust Linear Regression

version (2.53 KB) by Zachary Danziger
Quickly perform linear regression that is robust to outliers.


Updated 29 Sep 2015

View License

This function executes a fast version of the non-parametric Theil-Sen robust linear regression algorithm by finding the median slope between all pairwise combinations of points in a given data set.
For my application I needed to run a robust regression on large data sets (many thousands of points), but the implementations I found on the File Exchange were far too slow (see figure). This code is substantially faster, and for large data sets can be two orders of magnitude faster than those currently available.

Cite As

Zachary Danziger (2021). Theil-Sen Robust Linear Regression (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Theil–Sen estimator

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!