Return the Discrete Cosine Transform of arbitrary type sequence x.
Parameters :  x : array_like
type : {1, 2, 3}, optional
n : int, optional
axis : int, optional
norm : {None, ‘ortho’}, optional
overwrite_x : bool, optional


Returns :  y : ndarray of real

See also
Notes
For a single dimension array x, dct(x, norm='ortho') is equal to MATLAB dct(x).
There are theoretically 8 types of the DCT, only the first 3 types are implemented in scipy. ‘The’ DCT generally refers to DCT type 2, and ‘the’ Inverse DCT generally refers to DCT type 3.
There are several definitions of the DCTI; we use the following (for norm=None):
N2
y[k] = x[0] + (1)**k x[N1] + 2 * sum x[n]*cos(pi*k*n/(N1))
n=1
Only None is supported as normalization mode for DCTI. Note also that the DCTI is only supported for input size > 1
There are several definitions of the DCTII; we use the following (for norm=None):
N1
y[k] = 2* sum x[n]*cos(pi*k*(2n+1)/(2*N)), 0 <= k < N.
n=0
If norm='ortho', y[k] is multiplied by a scaling factor f:
f = sqrt(1/(4*N)) if k = 0,
f = sqrt(1/(2*N)) otherwise.
Which makes the corresponding matrix of coefficients orthonormal (OO' = Id).
There are several definitions, we use the following (for norm=None):
N1
y[k] = x[0] + 2 * sum x[n]*cos(pi*(k+0.5)*n/N), 0 <= k < N.
n=1
or, for norm='ortho' and 0 <= k < N:
N1
y[k] = x[0] / sqrt(N) + sqrt(1/N) * sum x[n]*cos(pi*(k+0.5)*n/N)
n=1
The (unnormalized) DCTIII is the inverse of the (unnormalized) DCTII, up to a factor 2N. The orthonormalized DCTIII is exactly the inverse of the orthonormalized DCTII.
References
http://en.wikipedia.org/wiki/Discrete_cosine_transform
‘A Fast Cosine Transform in One and Two Dimensions’, by J. Makhoul, IEEE Transactions on acoustics, speech and signal processing vol. 28(1), pp. 2734, http://dx.doi.org/10.1109/TASSP.1980.1163351 (1980).