Previous Up Next

9.2.8  Polynomial regression: polynomial_regression polynomial_regression_plot

The polynomial_regression command finds a more general polynomial y=a0xn + … + an which best fits a set of data points.


Example.
Input:

polynomial_regression([[1,1],[2,2],[3,10],[4,20]],3)

or:

polynomial_regression([1,2,3,4],[1,2,10,20],3)

Output:




5
6
,
17
2
,−
56
3
,12


so the best fit polynomial will be y = (−5/6)x3 + (17/2)x2 − (56/3)x + 12.


The polynomial_regression_plot command draws the best fit polynomial.


Example.
Input:

polynomial_regression_plot([1,2,3,4],[1,2,10,20],3)

Output:


Previous Up Next