簡體   English   中英

使用 Numpy Convolve 時振幅在變化

[英]The amplitude is changing when using Numpy Convolve

如何使以下正方形和高斯統一之間的卷積幅度?

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 的總和:

g = np.convolve(A, f, mode = 'same') * dt / np.sum(f)

假設dt也是 1,該圖會根據要求產生 1 的幅度。一般來說,幅度正好是dt

dt=1 的卷積結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM