# Correlation between frequency and initial phase estimates using FFT

Why is there a high negative correlation between frequency estimation errors and initial phase estimation errors when measured using FFT? I have a simple code showing this negative correlation. is there a known explanation for that? here is the code

clear all;clc;close all;
%%
T = 0.2;
fs = 500;
f = 200;
ts = 1/fs;
snr = 5;
n = fs*T;
t = linspace(0,T-ts,n);
theta = 0.1;
y = exp(1i*2*pi*(f.*t + theta));
for count = 1:2000
count;
yy  =  awgn(y,snr,'measured');
NFFT = 2^16;
fVals = fs/NFFT.*[0:NFFT-1];
X = fft(yy,NFFT)./n;
plot(abs(X))
[~,M] = findpeaks(abs(X),'MinPeakheight',0.8);
measuredAngle = angle(X(M))/2/pi;
errfreq(count) = fVals(M) - f;
errph(count) = measuredAngle - theta;
end
cov(errfreq,errph)
corrcoef(errfreq,errph)

ans =
1.0000   -0.8506
-0.8506    1.0000


## 1 Answer

It's a spurious artifact due to not referencing your phase generation to the center of your data window, and not doing an fftshift before the fft to place your phase reference point at fft input index 0.

e.g. For varying frequencies, either you have to know, generate, or want the phase at location T/2 of your continuous sinusoid. The phase result of an FFT after an fftshift will produce an estimate of the phase at T/2 for comparison. For continuous signals, when using this fftShift, interpolation to improve phase estimation referenced to the center point is possible (Sinc kernel better than linear or polynomial).

This has to be done anytime the input signal isn't absolutely locked to be perfectly integer periodic within the fft length in order to get reasonable phase measurement results. e.g. for any sweeping, variable, or unknown frequencies.

Otherwise the phase will toggle during the frequency sweep. This is because non-integer periodic sinusoids have a circular discontinuity at the window boundaries, and this discontinuity changes sign during frequency sweeps, causing the FFT phase result to have a discontinuity. An fftshift moves this discontinuity away from the beginning or phase measurement point of an FFT, which is the reference point where both the cosine and sine, or real and imaginary components of the FFT basis vectors start with a phase of zero.

• If it is a spurious artifact then why does this negative correlation appear even in the CRLB of estimating an unknown phase and frequency of a sinusoid [1,2]? [1] Brown III, D. Richard, Yizheng Liao, and Neil Fox. "Low-complexity real-time single-tone phase and frequency estimation." IEEE Military Communication (2010). [2] Hosseinbor, A. Pasha, and Renat Zhdanov. "2D Sinusoidal Parameter Estimation with Offset Term." arXiv preprint arXiv:1702.01858 (2017). – Amro Nov 14 '19 at 19:22
• Note that the initial results from a bare FFT (no post processing) are not ideal LB estimators. – hotpaw2 Nov 15 '19 at 1:35