I’m trying to gain a deeper understanding of what the cross-spectral density of two signals represents. I know how to compute it, and I know it represents a covariance of sorts, as it appears in the formula for coherence. It’s the nature of the “similarity” that I’m unclear about.
As an example, I'm sampling from two continuous signals at a rate of $f_s=100$ Hz for a period of one second.
t = np.arange(0, 1, 0.01);
N = len(t)
dt = t[1] - t[0]
fs=1/dt
f0=3
f1=5
x=np.cos(2np.pif0t)+np.cos(2np.pif1t)
phase_shift=.7dt
phase_shift_noisy=phase_shift+np.random.uniform(low=-.055, high=.055, size=(N,))
y=np.cos(2np.pif0(t-phase_shift))+np.cos(2np.pif1*(t-phase_shift_noisy))
So the phase difference between $x$ and $y$ at the frequency 3 Hz is constant, whereas the phase difference at 5 Hz is not constant due to the added noise. The plot of the signals looks as follows:
The plot of the cross-correlation of the signals:
The plot of $|P_{xy}|$ from 0 to 50 Hz, where $P_{xy}$ denotes the cross-spectral density:
I obtained the same plot two ways: By computing the DFT of the cross-correlation and by computing the product $|X_f \overline{Y}_f |$, where $X_f$ and $Y_f$ denote the DFT of $x$ and $y$, respectively.
The graph of $|P_{xy}|$ has spikes at 3 Hz and 5 Hz, as I would expect. However, the height at 5 Hz is smaller, which I attribute to the fact the phase difference at that frequency is not constant.
Question 1: In general, does the magnitude of $P_{xy}$ at a frequency describe how close the lag between the two signals at that frequency is to being constant? If so, am I correct that the coherence between $x$ and $y$ at 3 Hz is one, whereas the coherence at 5 Hz is less than one? (Since coherence is obtained by dividing $|P_{xy}|^2$ by the product $P_{xx}P_{yy}$?)
Question 2: Given that $P_{xy}$ at a frequency is complex, what does its argument tell me?


