首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用卷积积分拟合指数衰减-

使用卷积积分拟合指数衰减-
EN

Stack Overflow用户
提问于 2018-07-17 02:35:14
回答 2查看 1.5K关注 0票数 2

我拟合了以下数据,其中t: time (s),G: count,f:冲量函数:

代码语言:javascript
复制
 t      G      f 
-7200   4.7     0
-6300   5.17    0
-5400   4.93    0
-4500   4.38    0
-3600   4.47    0
-2700   4.4     0
-1800   3.36    0
 -900   3.68    0
    0   4.58    0
  900   11.73   11
 1800   18.23   8.25
 2700   19.33   3
 3600   19.04   0.5
 4500   17.21   0
 5400   12.98   0
 6300   11.59   0
 7200   9.26    0
 8100   7.66    0
 9000   6.59    0
 9900   5.68    0
10800   5.1     0

使用以下卷积积分:

更具体地说:

其中:lambda_1 = 0.000431062lambda_2 = 0.000580525

用于执行该拟合的代码为:

代码语言:javascript
复制
#Extract data into numpy arrays
t=df['t'].as_matrix()
g=df['G'].as_matrix()
f=df['f'].as_matrix()
#Definition of the function
def convol(x,A,B,C):
    dx=x[1]-x[0]
    return A*np.convolve(f, np.exp(-lambda_1*x))[:len(x)]*dx+B*np.convolve(f, np.exp(-lambda_2*x))[:len(x)]*dx+C

#Determination of fit parameters A,B,C
popt, pcov = curve_fit(convol, t, g)
A,B,C= popt
perr = np.sqrt(np.diag(pcov))

#Plot fit
fit = convol(t,A,B,C)
plt.plot(t, fit)
plt.scatter(t, g,s=50, color='black')
plt.show()

问题是我的拟合参数A和B太低,没有物理意义。我想我的问题与步长dx有关。它应该趋向于0,以便将my sum (np.convolve()对应于卷积的离散和)近似为一个整数。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51368151

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档