Reputation: 396
How can I make the amplitude of the convolution between the following square shape and gaussian unity?
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')
As you can see, in figure(2) the amplitude is approx 4.4. I would like to have it unity. How can I achieve that?
Upvotes: 1
Views: 1083
Reputation: 2801
If you want the convolution of your two signals to be scaled to your gaussian function, you need to normalize. The easiest way of doing this is dividing by the sum of f:
g = np.convolve(A, f, mode = 'same') * dt / np.sum(f)
The plot yields an amplitude of 1 as requested, given that dt
is also 1. Generally speaking, the amplitude will be exactly dt
.
Upvotes: 2