We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ed3db9 commit 5372836Copy full SHA for 5372836
contents/convolutions/convolutional_theorem/code/python/convolutional_theorem.py
@@ -1,16 +1,21 @@
1
from scipy.fft import fft, ifft
2
import numpy as np
3
4
+# using the convolutional theorem
5
def convolve_fft(signal1, signal2):
6
return ifft(np.multiply(fft(signal1),fft(signal2)))
7
-
8
+# Random distribution in x
9
x = np.random.rand(100)
10
+
11
+# Gaussian signals
12
y = [np.exp(-((i-50)/100)**2/.01) for i in range(1,101)]
13
14
x /= np.linalg.norm(x)
15
y /= np.linalg.norm(y)
16
17
+# Convolving the two signals
18
fft_output = convolve_fft(x, y)
19
20
np.savetxt("fft.dat", fft_output)
21
0 commit comments