I know that the cepstrum is mainly computed as follow: $ C_{r}={\mathcal {F}}^{-1}\left\{\log({\mathcal {|{\mathcal {F}}\{f(t)\}|}})\right\} $

What I am wondering is if I should take the whole fourier transform or only half of it when dealing with real discrete data (which leads to a symmetric DFT). I have seen different implementations on the web (half, whole).

So using python should it be:

# Implementation 1
spectrum = np.fft.fft(x, n=n)
ceps = np.fft.ifft(np.log(np.abs(spectrum))).real


# Implementation 2
spectrum = np.fft.rfft(x, n=n)       # Here this is rfft instead of fft
ceps = np.fft.ifft(np.log(np.abs(spectrum))).real

As one can expected, results are strongly different (tested on a random x of size 100):


My guess is the first is the right one, but I feel like adding the symmetric part has a strong impact so I would like to be sure.

Any help would be appreciated, thanks a lot


Your Answer

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

Browse other questions tagged or ask your own question.