# Questionable implementation of DCT kernel in Ceps.cpp

*Created by: pkorshunov*

@laurentes and @khoury: Could you please check this issue?

DCT kernel is implemented in Ceps.cpp (see line 103):

m_dct_kernel = dct_coeff * blitz::cos(M_PI*(i+1)*(j+0.5)/(double)(m_n_filters));

I'm not sure if using '(i+1)' index instead of 'i' in the DCT formula is correct. I suspect it is a bug. According to Wikipedia (https://en.wikipedia.org/wiki/Discrete_cosine_transform) and Matlab (http://ch.mathworks.com/help/signal/ref/dct.html), DCT-II, which seems to be the targeted implementation here, should have 'i' instead of 'i+1' as an index.

Also, for the normalization (see Ceps.cpp, line 103): double dct_coeff = m_dct_norm ? (double)sqrt(2./(double)(m_n_filters)) : 1.;

It seems the normalization is not correct either, since if we choose to use it, we should multiply zeros coefficient by 1/sqrt(2). Here is a clear formula and implementation: https://unix4lyfe.org/dct-1d/