# What determines the accuracy of the phase result in a DFT bin?

What are the factors that affect the accuracy and precision for the phase that is given by the DFT?

Just thinking medium-hard about this, it occurs to me that it must have something to do with the window length $$L$$ and the sampling frequency $$F_s$$, and maybe the fundamental frequency that I'm interested in extracting?

I'm going to keep working on some of the math, but I'd like to start a discussion and get some insight for which way to look.

• Let $N$-point DFT of $x[n]$ be $X[k] = |X[k]| e^{j \phi(k) }$ where $\phi(k)$ is the samples of the continuous phase function $\phi(\omega)|_{\omega = \frac{2\pi k}{N}}$ associated with the DTFT $X(e^{j\omega})$ of $x[n]$. Now, what do you exactly mean by phase resolution? – Fat32 Nov 6 '18 at 22:05
• I have not heard the term phase resolution come up in the context of a DFT, but since phase is the vertical axis, the only think I can think of that would dictate this would be the quantization of the phase, in the case of a fixed point implementation. – Dan Boschen Nov 6 '18 at 23:39
• resolution can mean more than a few things but is typically interpreted as how close 2 tonals can be distinguished as 2 tonals. it isn’t clear how that translates to phase – user28715 Nov 7 '18 at 4:54
• @StanleyPawlukiewicz Yes that would be "frequency resolution" in the case of "tonals", specifically how close we can resolve two frequencies. So therefore I would think "phase resolution" would/could mean how close we can resolve two signals with different phases using a phase estimation algorithm. I have not seen the term phase resolution applied in the frequency domain where we have phase vs frequency (I have seen it applied it in the time domain on a single frequency working with atomic clocks where we use phase and time interchangeably depending on the normalization of the axis) – Dan Boschen Nov 7 '18 at 12:09
• @Fat32 I mean, when I extract the magnitude and phase of a particular frequency bin, how precise can I be with the phase? I know that if I sample for one second, the bins of the result are spaced 1 Hz apart. Each bin in the phase array must have a maximum number of significant figures associated with it. For example, if I have 1 Hz resolution in the frequency bins and I sampled at, say, 8.192 kHz, can I report 10°? 6°? 5.7°? 5.733°? – Ben S. Nov 8 '18 at 0:59

If we refer to "phase resolution" as how many decimal places we can use for an estimate of the phase (such as the phase reported by one bin of the FFT), then this phase resolution is a time domain characteristic, and we would need to use the statistics of the signal involved in order to determine the useful precision. We cannot provide this experimentally based on the having one sample result alone; this would be equivalent to providing an average and then from that one average result alone, being able to determine its accuracy and precision, which is not possible without knowledge of the statistics of the signal.

Each bin in the frequency domain reports the magnitude and phase for that particular frequency. The OP used this as helpful analogy in his comments to help explain what it is he is really looking for, and specifically being able to present a precision on that phase estimate, and looking for the relationship between the time observation and the ability to resolve phase (increase precision).

For context with the rest of my response, let us first review the DFT computation and specifically for a single frequency bin which provides a magnitude and phase result. One bin in an FFT is the result of a time-domain correlation of the signal with the specific frequency of that bin. A time domain correlation is simply an average of the complex signal, and in this case after we have frequency shifted the signal back to DC (this is what occurs in the DFT computation).

For one bin $$k\omega_o$$ which is at a multiple $$k$$ of the fundamental frequency $$\omega_o$$ which is $$2\pi/T$$ with T being the duration of the time domain signal (or in Hz simply $$1/T$$) given as:

$$G(k) = \frac{1}{N}\Sigma_{n=0}^{N-1} g(t)e^{-j k \omega_o n}$$

We see that to compute the complex value of that bin we first frequency shift (by de-rotating) the spectral content of that bin and then do a simple low pass filter by averaging.

Thus if we want to know the accuracy of that result, we want to understand the accuracy of any time domain signal after the result of averaging. With that I respond:

The OP well understands the relationship between frequency resolution and the duration of the time domain sample that was used in the DFT, which is simply $$1/T$$ where T is the duration when we use an equivalent noise bandwidth in the frequency domain (to state simply, two distinct frequency tones will appear as one DFT bin if the frequency spacing is significantly less than $$1/T$$, and distinct tones when the spacing is significantly more than $$1/T$$.) This does suggest loosely how many decimal places we could use to report what frequency a single tone is at in the DFT. That frequency result is the correlation over that duration to the frequency in that particular bin, and is an averaged result for that duration used.

The phase, being the derivative of frequency, will have a slope vs time as derived directly from the frequency resolution previously described, so we can readily quantify the precision of that slope, and this result is the mean slope over the duration of observation.

If we want to consider the accuracy of the magnitude and/or phase of any one sample (one bin in the frequency domain), we must then resort to statistical measures and understand how that phase may have deviated from the linear slope over the observation interval.

The magnitude and phase accuracy of that estimate are similar quantities describing the complex value for that bin, so the phase accuracy is more consistent with the magnitude accuracy and perhaps easier to conceptualize in how we define the accuracy of the magnitude. The accuracy of both are similarly driven by the duration of observation, and we would typically approach this as a statistical problem based on the temporal characteristics of the signal and the noise. Quantization of the vertical axis is a contributor, but other noise sources may be present and we also must consider the stationarity of the signal in deriving such estimates.

A VERY useful and graphical statistic demonstrating phase and frequency accuracy vs observation interval is the Allan Variance (and Allan Deviation, or affectionately known as ADEV). This along with a similar metric TDEV (time deviation) is a widely used tool in the clock community (atomic clocks, frequency standards, GPS, etc) and I will provide a brief example from the example graph of ADEV shown below that I grabbed from http://leapsecond.com by googling ADEV images (a great site by the way if you want to dive deaper in into ADEV).

To attempt a brief explanation of this plot for my salient points, the horizontal axis shows the averaging time $$\tau$$, and the vertical axis shows an accuracy metric in terms of fractional frequency (the frequency error divided by the frequency of the clock). If the signal was stationary and the noise white, the accuracy would improve at a rate of $$1/\sqrt{\tau}$$ which the plot is closer to on the left side with shorter averaging time. This does immediately tell us over what observation intervals we could use such simplifying statistics as a white and stationary process. The plot tells me I could average such a signal for up to 500 seconds and continue to improve my accuracy of the estimate through averaging (processing gain etc), and in a fixed point system as long as I increased my precision accordingly (think extended precision accumulators!). It also immediately tells me that if I averaged for 500 seconds, I would not get the full SNR processing gain that I would expect (the famous $$10Log(BW_{1}/BW_{2})$$ equation since the result is not 1E-12 at 100 seconds and therefore the trend came short of $$1/\sqrt{\tau}$$. But look at this interesting point- If I continued to average past that, my result would be less accurate!! This has such wide ramifications across all signal processing, such as using an equalizer that has a span that exceeds the delay spread of the channel, or too many taps in an FIR filter, or the limit of processing gain in a spread spectrum system such as GPS, and many other implementations where we are ultimately doing some sort of weighted average.

That said, the point is to determine an accuracy of the estimate of a sample (whether we use phase or magnitude parameters or both when describing complex samples), we must understand the statistics of the signal and noise involved, and then proceed with statistical approaches in communicating precision and confidence. For example, if we knew the the process was white and stationary, and we knew what the phase over all the frequency bins should be, we could then use the error terms for every bin to estimate the accuracy of any one bin. Without knowing that, if the system was ergodic and stationary, we could use successive fft captures to determine a statistical estimate of accuracy. (And as explained, there is often a shorter duration of time in which it is valid to make such an estimate, therefore in our favor to make the captures as soon as possible with minimum delay in between). If the system is white, then each sample is independent of the next, and therefore shifting by one sample and taking a new FFT would be a completely independent result; we can do a sliding FFT to be able to get many more captures in less time and further improve the confidence of our result). The point is in all cases we have no way of defining the accuracy from one sample alone unless deduced from known signal statistics.