Cepstrum handling of zero bins

A potentially lazy question –

Consider:

a = Signal.sineFill(64, (1 .. 20).reciprocal);
a = a.as(Array).dup(8).flat.as(Signal);

This is a band limited sawtooth which, within the 512-sample window, has frequency = 8.

The FFT of this should have energy at bins 0, 8, 16 … 160, and 0 elsewhere. At least when I just tried this, bins 1-7, 9-15 etc. are real zeroes: Complex(0, 0).

The complex cepstrum is the complex logarithm of this, IFFT-ed.

The logarithm of 0 is -inf, which doesn’t work very well in IFFT OK, taking my own advice to avoid saying “doesn’t work” – anyway, -inf fed into IFFT produces a lot of NaN, whose analytical value I find somewhat dubious.

I’m certain that I’m missing something…? What is it?

(I didn’t try power cepstrum yet because the logarithm of the real-valued magnitude will still produce -inf because the magnitude of 0 + 0i is 0, log(0) == -inf kaboom.)

hjh

Maybe you could consider adding a (tiny) offset to the fft bin values to avoid zero values while at the same time not disturbing the original signal too much.

Also see here: matlab - Can't compute real cepstrum of real signal - Signal Processing Stack Exchange

Thanks, will try when I have time.

hjh

@jamshark70, we’ve included an implementation of the real cepstrum in SignalBox.

At this moment I can’t recall why we didn’t include the complex cepstrum.

Interestingly enough, these authors have proposed a DCT approach, which could be useful to try:

R. Muralishankar and A. G. Ramakrishnan, “DCT based pseudo complex cepstrum,” 2002 IEEE International Conference on Acoustics, Speech, and Signal Processing , 2002, pp. I-521-I-524, doi: 10.1109/ICASSP.2002.5743769.

Thanks – I’m not certain that I need the complex cepstrum, just playing around.

I did try, this morning, substituting a small nonzero value for the zeroes and I did get what appeared to be a valid result (it did correctly pick up the periodicity).

I probably can’t access the paper but interesting to know there are other approaches.

Thanks!
hjh