1
$\begingroup$

What is the difference between the Hermitian FFT and DFT? Particularly in Python, there are two functions fft and hfft.

numpy.fft.hfft(signal) vs numpy.fft.fft(signal)

What I simply could find out is: The Hermitian has to do something with symmetry and needs 50 times longer to calculate, while producing a 'slightly' different result than the 'discrete' FFT. (tested on an audio file of machinery sounds and length of 1.5 sec).

$\endgroup$
1
$\begingroup$

You have to understand that fft is the general function, which always works. hfft, fftr and their derivatives are optimized for special signal constellations and should either be faster or more accurate (if this is at all necessary with modern floating point accuracy).

The hfft function is used, when you expect the spectrum to be real-valued. This happens, if your input signal has even symmetry. I doubt that your audio signal does have this property. Have you been looking for fftr (i.e. fft for a real-valued signal)?

In case your input signal has the even symmetry property, the output of fft and hfft should be exactly the same (up to numerical residual errors). Also, hfft should be a bit faster in this case (otherwise, it would make no sense to use it).

$\endgroup$
  • 1
    $\begingroup$ hfft is basically the same as irfft (just with different sign convention). – Are you sure these are ever faster or more accurate? Actually I'd suspect they're all implemented with the same fft primitive and just automatically take care of adding/removing the symmetry-redundant parts of the signal or imaginary parts of the spectrum. $\endgroup$ – leftaroundabout Mar 28 '17 at 14:40
  • $\begingroup$ @leftaroundabout Hm, I'm not sure. I have followed the source code of the various fft functions until github.com/numpy/numpy/blob/v1.12.0/numpy/fft/fftpack.c where still different implementations for fft and rfft etc. are there. So, I'm not sure, if it is just the plain fft with some post-processing. $\endgroup$ – Maximilian Matthé Mar 28 '17 at 15:26
  • $\begingroup$ i never heard it called "hfft()" $\endgroup$ – robert bristow-johnson Mar 29 '17 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.