We create a dataset that we then fit with a straight line $f(x) = m x + c$.
npoints = 20
slope = 2
offset = 3
x = np.arange(npoints)
y = slope * x + offset + np.random.normal(size=npoints)
p = np.polyfit(x,y,1) # Last argument is degree of polynomial
To see what we've done:
impor...