# Why would you use DCT as oppose to DFT for detecting oscillation in a signal?

For my project, I needed to detect the primary oscillation frequency in a signal data. As I googled around, it turns out that DCT is the best tool to find this (http://www.mech.pku.edu.cn/robot/teacher/wangjiandong/WangHuangLu_ImprovedDCT_CEP_2013.pdf)

My question is: why would you base the analysis on DCT, and not DFT? What would happen if I were to apply the same analysis but with DFT? I can't accept that DCT is "faster" since for the practice of detecting oscillation, even in real time, both are "fast enough" and so speed and computation complexity should not be a factor into deciding which to pick!

-

Compared to the DFT, the DCT has a better "energy compaction" property for narrow-band oscillations whose frequency is not exactly periodic within the DFT window's length. This energy compaction may make it easier to spot or discriminate spectral peaks that are "between bins" in an FFT result, and/or that are barely above a given noise floor.

-
Sorry, can you expand on your first statement? What exactly do you mean frequencies that are not exactly periodic within the window's length? Do you mean a periodic signal that has been damped out because of other frequencies present in the signal? –  Kousha Apr 15 at 23:58
A frequency that does not have an integer number of periods within the windows length. e.g. 5.1 periods versus 5 periods –  hotpaw2 Apr 16 at 0:27
One way to think of an FFT is as filter bank with identical filters spaced evenly across frequency. The FFT size and window control the filter response in terms of rejection and transition bandwidth. Isn't this same line of thought applicable to the DCT? It seems like you're saying the frequency resolution of the DCT is better than the FFT; I'm having a hard time seeing this. Any references? –  impoliticus Apr 16 at 0:31
The default FFT rectangular window does not have good energy compaction properties except for frequencies that are exact (or very close to) multiples of Fs/N. Non-rectangular FFT windows produce less broadband "spectral leakage" but can be lossy near the window's ends. –  hotpaw2 Apr 16 at 0:40
Also, increasing an FFT's size to gain more frequency resolution does not really work if one does not have more data to fill the longer FFT. –  hotpaw2 Apr 16 at 0:48

Just keepin' it $\Re$eal.

The DFT records the timing offset of a particular sinusoid frequency as the phase of the complex coefficient. Since the DFT of a real signal is conjugate-symmetric, the corresponding negative frequency coefficient gets the same magnitude but negative phase. FFT routines frequently skip calculating the negative spectrum for real signals. This leaves NFFT/2+1 non-redundant complex coefficients, however the DC and Nyquist bins are completely real. It would be possible to combine the DC and Nyquist bin together, making zero growth in data size (for even length signals anyway).

But this kind of flipping between Complex and Real structure may not be convenient for analysis or computation.

The DCT captures essentially the same information about the real signal, except the timing of the sinusoid is encoded as the sum of cosine waves. The DCT has the advantage of representing a unitary transform without mixing real and complex numbers. The DFT is also unitary, but it maps $\mathbb{R^N} \rightarrow \mathbb{C^N}$.

-