Skip to content
Snippets Groups Projects
Commit 7ca7d65a authored by Keyser, Johannes's avatar Keyser, Johannes
Browse files

Small fixes in documentation.

parent 7000c91f
Branches
No related tags found
No related merge requests found
......@@ -8,12 +8,12 @@ A stand-alone Theil-Sen estimator for robust regression in Matlab.
### Theil-Sen estimator
A [Theil-Sen estimator](https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator) provides robust linear regression in the 2D plane:
A [Theil-Sen estimator](https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator) provides robust, simple linear regression in the 2D plane:
The resulting estimates of slope and intercept are relatively insensitive to outliers.
The present implementation of [TheilSen.m](TheilSen.m) is exact but "naive":
The implementation of [TheilSen.m](TheilSen.m) is exact but "naive":
It generates the set of all pairs of the _n_ input samples, resulting in an overall complexity of _O(n²)_ in both speed and space.
The resulting slope and offset are the median slope and offset of all lines defined by the data point pairs.
The resulting slope and offset are the median slope and offset of the lines defined by all data point pairs.
(Note that other implementations of the algorithm achieve better complexity, and are thus much faster for large amounts of data points.)
......
function [b1, b0] = TheilSen(X, y)
% THEILSEN performs Theil-Sen robust, simple linear regression(s) of X on y.
%
% Note that multiple predictor variables in X are treated as independent
% simple regressions; don't confuse the output with multiple regression.
% Note that two or more predictor variables in X are treated as independent
% simple regressions; do not confuse the output with multiple regression.
%
% THEILSEN treats NaNs in X or y as missing values, and ignores them.
%
......
......@@ -30,7 +30,7 @@ data_y(outlr_idx) = outlr_y;
est_ls = [ones(N_total, 1), data_x] \ data_y;
% Estimate Theil-Sen parameters.
[m, b] = TheilSen([data_x, data_y]);
[m, b] = TheilSen(data_x, data_y);
est_ts = [b, m];
% Plot everything and add comparison of estimates to title.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment