Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Fit a line to data points in n-dimensional space
ResourceFunction["LineFit"][pts] returns a Line that fits best through the points pts. | |
ResourceFunction["LineFit"][pts,"Association"] returns an Association containing properties of the best fit line. |
Fit a line in 2D:
| In[1]:= |
|
| Out[1]= |
|
Compare the points and the fit:
| In[2]:= |
|
| Out[2]= |
|
Do a fit with points in 3D:
| In[3]:= |
|
| Out[3]= |
|
Get a Dataset with all the fitting details:
| In[4]:= |
|
| Out[4]= |
|
Compare the result of LineFit with the result of computing the orthogonal fit through the definition:
| In[5]:= |
|
| In[6]:= |
|
| Out[6]= |
|
| In[7]:= |
|
| Out[7]= |
|
The one-argument case of LineFit is equivalent to the resource function OrthogonalLineFit:
| In[8]:= |
|
| In[9]:= |
|
| Out[9]= |
|
| In[10]:= |
|
| Out[10]= |
|
All points have to be numeric:
| In[11]:= |
|
| Out[11]= |
|
All points have to be in the same dimension:
| In[12]:= |
|
| Out[12]= |
|
Real numbers have to be used:
| In[13]:= |
|
| Out[13]= |
|
Do a fit in 10D:
| In[14]:= |
|
| Out[14]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License