如何使以下正方形和高斯单位之间的卷积幅度大?
L = 5
x = 1
t_total = L+2*x
tlist = np.linspace(0,t_total,100)
# Square pulse of length L and unit amplitude centered at x+L/2
A = (heaviside(tlist - x, 0) - heaviside(tlist - (L+x), 0))
# Gaussian with mean (x+L/2) and std 1
f = np.exp(-pow(tlist-(x+L/2),2)/2)
figure(1)
plt.plot(tlist, A)
plt.plot(tlist, f)
# Convolution
g = np.convolve(A, f, mode = 'same') * dt
figure(2)
plt.plot(tlist, g, 'g')
图1)
图(2)
如您所见,在图(2)中,振幅约为4.4。我要团结。我该如何实现?
最佳答案
如果要将两个信号的卷积缩放到高斯函数,则需要进行归一化。最简单的方法是将f除以f:
g = np.convolve(A, f, mode = 'same') * dt / np.sum(f)
考虑到
dt
也是1,该图将按要求产生幅度1。通常来说,幅度将恰好是dt
。关于python - 使用Numpy Convolve时振幅会发生变化,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59787032/