Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Polynomial fit of a given set of data, represented as a spline curve
ResourceFunction["PolynomialFitCurve"][{{x1,y1},{x2,y2},…},n] returns a BSplineCurve representing the least-squares, degree-n polynomial fit of the points {xi,yi}. |
Here is some data:
In[1]:= |
A BSplineCurve representing a quadratic fit to the data:
In[2]:= |
Out[2]= |
Show the data and the polynomial fit together:
In[3]:= |
Out[3]= |
Compare cubic and quartic polynomial fits to a set of data:
In[4]:= |
Out[5]= |
Here is some data:
In[6]:= |
For degree 1, PolynomialFitCurve gives a result equivalent to the result of the resource function TrendLine:
In[7]:= |
Out[8]= |
Wolfram Language 12.3 (May 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License