# DFT - Discrete (Fast) Fourier Transform

Calculates the discrete fast Fourier transformation for amplitude and phase.

## Syntax

DFT(X, Order, Component, Return_type)
X
is the univariate time series data (one dimensional array of cells (e.g. rows or columns)).
Order
is the time order in the data series (i.e. the first data point's corresponding date (earliest date=1 (default), latest date=0)).
Order Description
1 ascending (the first data point corresponds to the earliest date) (default)
0 descending (the first data point corresponds to the latest date)
Component
is the input frequency component order. If missing, component 0 is assumed. If negative, an array of all components is assumed.
Return_type
is a number that determines the type of return value: 1 (or missing) = Amplitude , 2 = Phase.
RETURN_TYPE NUMBER RETURNED
1 or omitted Amplitude
2 Phase

## Remarks

1. The input time series may include missing values (e.g. #N/A, #VALUE!, #NUM!, empty cell) at either end, but they will not be included in the calculations.
2. The input time series must be homogeneous or equally spaced.
3. if the component value is negative, the DFT function returns an array of amplitudes (or phase) values for all components in the sample data.
4. The first value in the input time series must correspond to the earliest observation.
5. The frequency component order, $k$, must be a positive number less than $N$, or the error (#VALUE!) is returned.
6. The DFT returns the phase angle in radians, i.e. $0 \lt \phi \lt 2 \times \pi$.
7. The discrete Fourier transformation (DFT) is defined as follows:

$$X_k = \sum_{j=0}^{N-1} x_j e^{-\frac{2\pi i}{N} j k}$$

Where:
• $k$ is the frequency component
• $x_0,...,x_{N-1}$ are the values of the input time series
• $N$ is the number of non-missing values in the input time series
8. The Cooley-Tukey radix-2 decimation-in-time fast Fourier transform (FFT) algorithm divides a DFT of size N into two overlapping DFTs of size $\frac{N}{2}$ at each of its stages using the following formula:

$$X_{k} = \begin{cases} E_k + \alpha \cdot O_k & \text{ if } k \lt \dfrac{N}{2} \\ E_{\left (k-\frac{N}{2} \right )} - \ \alpha \cdot O_{\left (k-\frac{N}{2} \right )} & \text{ if } k \geq \dfrac{N}{2} \end{cases}$$
Where:
• $E_k$ is the DFT of the even-indicied values of the input time series, $x_{2m} \left(x_0, x_2, \ldots, x_{N-2}\right)$
• $O_k$ is the DFT of the odd-indicied values of the input time series, $x_{2m+1} \left(x_1, x_3, \ldots, x_{N-2}\right)$
• $\alpha = e^{ \left (-2 \pi i k /N \right )}$,
• $N$ is the number of non-missing values in the time series data.
9. The unit frequency of the DFT is $\frac{2\pi}{N}$, where $N$ is the number of non-missing observations.

## Examples

Example 1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
A B
Date Data
January 10, 2008 0.66
January 11, 2008 0.02
January 12, 2008 0.54
January 13, 2008 0.21
January 14, 2008 0.73
January 15, 2008 0.37
January 16, 2008 1.00
January 17, 2008 0.42
January 18, 2008 0.99
January 19, 2008 0.04
January 20, 2008 0.23
January 21, 2008 0.31
January 22, 2008 0.69
January 23, 2008 0.37
January 24, 2008 0.78
January 25, 2008 0.30
January 26, 2008 0.97
January 27, 2008 0.91
January 28, 2008 0.92
January 29, 2008 0.88
January 30, 2008 0.14
January 31, 2008 0.06
February 1, 2008 0.19
February 2, 2008 0.61

Formula Description (Result)
Amplitude for frequency 1 (1.171) Phase for frequency 1 (2.497)
Amplitude for frequency 2 (2.267) Phase for frequency 2 (3.708)
Amplitude for frequency 3 (1.136) Phase for frequency 3 (0.097)
Amplitude for frequency 4 (2.325) Phase for frequency 4 (0.067)
Amplitude for frequency 5 (1.408) Phase for frequency 5 (1.839)