I have been trying to find an efficient way to find the pattern of overlap for binary signals.
x = np.array([0,0,1,1])
x1= np.array([0,1,0,1])
print(x)
print(x1)
ft = np.fft.rfft(x)
ft1 = np.fft.rfft(x1)
print(ft1)
print(ft)
When I run the code I get this as the transform
[0 0 1 1]
[0 1 0 1]
[ 2.+0.j 0.+0.j -2.+0.j]
[ 2.+0.j -1.+1.j 0.+0.j]
When I do the inverse of the pointwise multiplication, using the code below.
np.fft.irfft(ft1*ft)
I get this
array([1., 1., 1., 1.])
I was expecting this
array([0, 0, 0, 1.])
I am curious from a math perspective why I am not getting my expected behavior.
Thank you in advance.
Your expectation is incorrect.
With the DFT, the convolution theorem states that point wise multiplication in one domain becomes CIRCULAR convolution in the other domain. With circular convolution, the values wrap around to the other side. And the circular convolution of the two vectors is [1, 1, 1, 1].