通过拟合python中的数据来绘制指数曲线

问题描述

我有x数组和y数组。我需要预测左右两侧的点(pareto前沿的点)(我不知道具体如何)。这就是为什么在点的第一次外推中使用它,但是它给出了线性 我试图将数据点拟合为指数曲线,但结果只给出了系数为A=1.0K=1.0C=232.49024883323932的直线。

我还尝试将我的数据拟合为3级的多项式函数,结果更好,但尾巴增加了


x=[263.56789586,263.56983885,263.57178259,263.57372634,263.57567008,263.57761383,263.57955759,263.58150134,263.58344509,263.58538884,263.5873326,263.66699508,263.5912201,263.59316385,263.59510762,263.59705135,263.59899512,263.60093885,263.60288261,263.60482637,263.60677014,263.60871386,263.61065764,263.61260141,263.61454514,263.6164889,263.61843266,263.62037642,263.62232019,263.62426392,263.62620767,263.62815143,263.63009519,263.63203894,263.63398269,263.63592645,263.63787021,263.63981396,263.64175772,263.64370148,263.64564523,263.64758898,263.64953274,263.65147649,263.65342024,263.655364,263.65730775,263.65925151,263.66119527,263.66313902,263.66508278,263.66702653,263.66897028,263.67091404,263.67285779,263.67480155,263.67674531,263.67868906,263.68063281,263.68257657,263.68452032,263.68646408,263.68840783,263.69035159,263.69229534,263.69423909,263.69618285,263.6981266,263.70007036,263.70201411,263.70395787,263.70590162,263.70784537,263.70978913,263.71173288,263.71367664,263.71562039,263.71756415,263.7195079,263.72145166,263.72339541,263.72533917,263.72728292,263.72922667,263.73117043,263.73311418,263.73505802,263.73700169,263.73894545,263.74088929,263.74283296,263.74477671,263.74672046,263.74866422,263.75060797,263.75255173,263.75449548,263.75613889,263.75617049,263.75587478]
y= [232.99031933,232.95558575,232.93713544,232.9214609,232.9072364,232.8939496,232.88133917,232.86925025,232.85758305,232.84626821,232.8352564,232.59299633,232.81389123,232.80326395,232.79262328,232.7819675,232.77129713,232.76061533,232.74992564,232.739233,232.72854327,232.717862,232.70719578,232.69655002,232.68593193,232.67534666,232.66479994,232.65429722,232.64384269,232.63344132,232.62309663,232.61281189,232.60259005,232.59243338,232.5823437,232.57232231,232.56237032,232.55248837,232.54267676,232.5329356,232.52326498,232.51366471,232.5041348,232.4946754,232.48528698,232.47597054,232.46672774,232.4575614,232.44847565,232.43947638,232.43057166,232.42177232,232.41309216,232.40454809,232.39615988,232.387949,232.37993719,232.37215305,232.36467603,232.35750509,232.35062207,232.34401067,232.33765646,232.33154649,232.32566912,232.32001373,232.31457099,232.30933224,232.30428981,232.29943675,232.29476679,232.29027415,232.2859539,232.28180142,232.2778127,232.27398435,232.27031312,232.26679651,232.26343235,232.26021888,232.25715486,232.25423943,232.25147212,232.24885312,232.24638301,232.24406282,232.24189425,232.23987999,232.23802286,232.23632689,232.2347971,232.23343943,232.23226138,232.23127218,232.2304829,232.22990751,232.22956307,232.22946832,232.22947064,232.22947062]
def func(x,a,b,c,d):
    #return a*x**3 + b*x**2 +c*x + d
    return a*np.exp(-b*x) + c

x = pareto_df['BSFC_bar_LET'].values
y = pareto_df['BSFC_RatedP'].values

popt,pcov = curve_fit(func,x,y)


print (popt[0],popt[1],popt[2],popt[3])

min_x=min(np.exp(x))-0.5*(max(np.exp(x))-min(np.exp(x)))
max_x=max(np.exp(x))+0.5*(max(np.exp(x))-min(np.exp(x)))
xnew= np.linspace(min(x),max(x),1000)  

plt.plot(x,y,'o')
plt.plot(xnew,func(xnew,*popt),label="Fitted Curve") 

plt.legend(loc='upper left')
plt.show()

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...