December 2017
Intermediate to advanced
386 pages
10h 42m
English
This code represents the main part of the function and how to solve it:
import numpyimport scipyimport matplotlib.pyplot as pltx=numpy.linspace(0,1,10)y=numpy.sin(x*numpy.pi/2)line=numpy.polyfit(x,y,deg=1)plt.plot(x,y,'.',x,numpy.polyval(line,x),'r')plt.show()
This gives the following plot that shows linear regression with polyfit:

Curve fitting is also possible with splines if we use the parameters wisely. For example, in the case of univariate spline fitting that we introduced before, we can play around with the weights, smoothing factor, the degree of the smoothing spline, and so on. If we want to fit a parabolic spline ...
Read now
Unlock full access