Fitting Lynx double eleven sales

Two-eleven sales recently saw the news of the news, here it fit. 


AS NP numpy Import Import matplotlib.pyplot AS PLT from scipy.optimize Import curve_fit # custom exponential function e # DEF FUNC (X, A, B, C): # return np.sqrt A * (X) * (B * np.square (x) + C) # cubic equation DEF F_3 (x, A, B, C, D): return A * x * x * x * x * x + B + C + D * x # x is defined , y coordinates of the point scattered X = [I + I in Range. 1 for (10)] X = np.array (X) NUM = [0.5, 9.36, 52 is, 191, 350, 571, 912, 1207, 1682.69, 2135.00] np.array = Y (NUM) # nonlinear least squares fit popt, pcov = curve_fit (F_3, X, Y) Print ( 'the fitting error is: {}' the format (pcov).) # Get inside popt fitting coefficients A Popt = [0] B Popt = [. 1] C = Popt [2] D = Popt [. 3] yvals = f_3 (x, a, b, c, d) # y values fit Print ( 'Popt:', Popt) Print ( 'factor A:', A) Print ( 'factor B:', B) Print ( 'coefficient C:', C) Print ( 'coefficients pcov:', pcov) Print ( 'coefficients yvals:', yvals) # drawing plot1 = plt.plot (x, y, 's', label = 'original values' ) Plot2 plt.plot = (X, yvals, 'R & lt', label = 'values polyfit') plt.xlabel ( 'X') plt.ylabel ( 'Y') plt.legend (LOC =. 4) # specify the legend bottom right of the plt.title ( 'curve_fit') plt.show ()


in conclusion:

IS X:
[. 1. 5. 4. 3 2. 6. 7. 9 10. 8]
Y IS:
[5.00000e-01 9.36000e + 00 5.20000e + 01 1.91000e + 02 3.50000e + 02 5.71000e + 02
9.12000e + 02 1.20700e + 1.68269e + 03 2.13500e + 03 03]
F1 IS:
[.15430847 27.54898601 57.14666667 -82.43744367]
P1 IS:
. 3 2
.1543 27.55 + X X - X + 82.44 57.15
predictive value: 2689.1466666666643
yvals IS:
[2.41251748 3.70219114 61.94153846 178.05641026 352.97265734
587.61613054 882.91268065 2141.9793007 1239.78815851 1659.16841492]

And this year's sales really quite close.

  

 

Guess you like

Origin www.cnblogs.com/aichiladeyu/p/11864964.html