Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the hyperplane that best fits a set of points
ResourceFunction["PlaneOfBestFit"][{p1,p2,…}] returns an InfinitePlane that minimizes the sum of squares of orthogonal distances to the 3D points pi. |
Generate a set of random points in space:
| In[1]:= | ![]() |
| Out[4]= | ![]() |
Find the plane of best fit:
| In[5]:= |
| Out[5]= |
Show the bestfit plane along with the points:
| In[6]:= |
| Out[6]= | ![]() |
Create a best-fit line for points in 2D. First generate a set of random data:
| In[7]:= | ![]() |
| Out[10]= | ![]() |
Find the line of best fit:
| In[11]:= |
| Out[11]= |
Show the bestfit line along with the points:
| In[12]:= |
| Out[12]= | ![]() |
Create points in 4D such that the spread along the last axis is much less than along the other three:
| In[13]:= | ![]() |
Create a best-fit 3D hyperplane to these points and obtain a normal vector close to {0,0,0,1}:
| In[14]:= |
| Out[14]= |
This work is licensed under a Creative Commons Attribution 4.0 International License