1# REGRESSION ------------------------------------------------------------------
2p0 = [-1, -3e-3, 1] # guessed params
3w, _ = opt.curve_fit(func, x_samp, y_samp, p0=p0)
4print("Estimated Parameters", w)
5
6# Model
7y_model = func(x_lin, *w)
8
9# PLOT ------------------------------------------------------------------------
10# Visualize data and fitted curves
11plt.plot(x_samp, y_samp, "ko", label="Data")
12plt.plot(x_lin, y_model, "k--", label="Fit")
13plt.title("Least squares regression")
14plt.legend(loc="upper left")
15
16# Estimated Parameters [-1.66301087 -0.0026884 1.00995394]