Say, I create a Hermitian complex signal using,
import numpy as np
t = np.arange(-4, 4)
z = np.exp(1j * t)
Here z
should be a complex signal with Hermitian Symmetry, as you can see below.
In [2]: t
Out[2]: array([-4, -3, -2, -1, 0, 1, 2, 3])
In [3]: z
Out[3]:
array([-0.65364362+0.7568025j , -0.98999250-0.14112001j,
-0.41614684-0.90929743j, 0.54030231-0.84147098j,
1.00000000+0.j , 0.54030231+0.84147098j,
-0.41614684+0.90929743j, -0.98999250+0.14112001j])
But when I take the Fourier Transform of this signal, I don't get a real spectrum,
In [8]: np.fft.fft(z)
Out[8]:
array([-1.38531768+0.7568025j, -7.02599565+0.7568025j,
2.57935201+0.7568025j, 0.93952139+0.7568025j,
0.41344309+0.7568025j, 0.08151870+0.7568025j,
-0.22205190+0.7568025j, -0.60961892+0.7568025j])
However, when I take the Hermitian FFT using the hfft
function, I get
In [10]: np.fft.hfft(z[:5])
Out[10]:
array([-1.38531768, -7.02599565, 2.57935201, 0.93952139, 0.41344309,
0.0815187 , -0.2220519 , -0.60961892])
This is the real component of the result I got using the regular fft
function.
I don't understand what I am doing wrong here. Shouldn't fft
be giving a result with a zero or almost-zero imaginary component when the input is Hermitian?
I feel like I am doing something wrong here regarding how the signal is presented to fft
.