Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Fit a line through a set of points using the Theil–Sen estimator
ResourceFunction["TheilSenLine"][data] uses the Theil–Sen estimator to fit a line through a set of points represented by data. | |
ResourceFunction["TheilSenLine"][xlist,ylist] uses the Theil–Sen estimator to fit a line through a set of points, where xlist and ylist respectively give the x and y coordinates of the points. | |
ResourceFunction["TheilSenLine"][…,x] returns an equation for the Theil-Sen line in terms of the variable x. |
Fit a line through the points (0,1),(1,1),(2.5,3) using the Theil–Sen estimator:
In[1]:= |
Out[1]= |
The output is of the form {m,b}, which represents a line fit of the form y=mx+b. Compare the fitted line to the original points:
In[2]:= |
Out[2]= |
Supply data given in the form of separate lists for the x and y coordinates:
In[3]:= |
Out[3]= |
Return a formula for the model by passing the predictor as an additional argument:
In[4]:= |
Out[4]= |
This work is licensed under a Creative Commons Attribution 4.0 International License