亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

考慮不確定性的高斯擬合

考慮不確定性的高斯擬合

慕婉清6462132 2021-08-05 17:59:08
我無法理解以下代碼有什么問題:import numpy as npimport matplotlib.pyplot as pltfrom scipy.odr import *def gauss(p,x):    return p[0]*np.exp(-(x-p[1])**2/(2*p[2]**2)+p[4]) + p[3]# Create a model for fitting.gg = Model(gauss)x = np.arange(0, 350)# Create a RealData object using our initiated data from above.data = RealData(x, y_data, sx=0, sy=y_data_err)# Set up ODR with the model and data.odr = ODR(data, gg, beta0=[0.1, 1., 1.0, 1.0, 1.0])# Run the regression.out = odr.run()# Use the in-built pprint method to give us results.out.pprint()x_fit = np.linspace(x[0], x[-1], 1000)y_fit = gauss(out.beta, x_fit)plt.figure()plt.errorbar(x, xy_data xerr=0, yerr=y_data_err, linestyle='None', marker='x')plt.plot(x_fit, y_fit)plt.show()這是從這里直接復制的,只更改了模型。我得到的錯誤是scipy.odr.odrpack.odr_error: number of observations do not match但據我所知beta0有五個參數,這gauss與工作需要一樣多。如果有人能指出錯誤來源或我的誤解,那就太好了。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 174 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號