# For two signals having a common frequency, w, and differing by a fixed phase shift, why is the coherence even defined at frequencies other than w?

This question is related to one posted a couple years ago at (Why the spectral coherence is unity for all frequencies between single-frequency time series and itself).

Suppose two signals have common frequency, $$\omega_0$$, and a fixed phase difference, $$\phi_0$$:

$$x(t)=\sin(2\pi \omega_0 t)$$ $$y(t)=\sin(2\pi \omega_0(t-\phi_0))$$

where $$t$$ varies over a set of discrete time samples. The coherence, in general, is defined as

$$Coh(\omega)=\frac{|P_{xy}(\omega)|^2}{P_{xx}(\omega)P_{yy}(\omega)},$$

where the numerator is the magnitude squared of the co-spectral density, and the denominator is the product of the corresponding power spectral densities.

If $$\omega=\omega_0$$ in the example above, then $$Coh(\omega_0)=1.$$

The mathematician in me is troubled by the fact that the coherence is even defined for any other frequency, $$\omega \ne \omega_0$$, since the definition results in an undefined quantity, $$\frac{0}{0}$$.

When I plot the coherence function for the above using a Matplotlib tool such as cohere(x,y), the function appears to equal one for all $$\omega$$. I gather, from the post at the above URL, that this stems from the numeric estimation tool being used.

But from a theoretical point of view, is $$Coh(\omega)$$ even defined in my example above, when $$\omega \ne \omega_0$$? Or is it just a convention to set it equal to 1?

From a theoretical view I would say it's undefined. The signals have no energy at this frequency and so the question becomes how much zero is correlated with zero which is non-sensical.

Keep in mind that whatever you do in a computer can only be done on discrete signals and not on the continuous ones you are using in you equation. Sometimes the discrete representation can be used as numerical approximation of the continuous one, but that depends a lot on the specific details.

You could define the coherence either as $$1$$ or you can make an argument that it's something like $$\delta(\omega-\omega_0)$$. What difference would it make? Can you think of an application where this would make an observable difference? If you can't, you can assume whatever you want.

I'm with you that $$Coh(\omega) = \begin{cases} 1 & \omega = \omega_0 \\ \mathrm{undefined} & \omega \ne \omega_0 \end{cases}.$$

I think if you wanted to use the value of $$Coh(\omega),\ \omega \ne \omega_0$$, you'd need to define what it meant for the problem at hand for it to be undefined.

Where coherence comes up is in practical use where the signal does not extend for infinite time- in this case we have a correlation between two signals at different frequencies that goes down as a Sinc function with the first nulls occurring at frequency offsets equal to $$\pm 1/T$$ (Sinc squared as a power quantity).

Thus we see that if the sinusoid did extend for $$t$$ over the range $$\pm \infty$$ that the correlation (and coherence) would be 0 for any frequency offset. For practical implementations we would always consider a finite observation interval.

See this post for further intuition in the effect of frequency offset and correlation for time limited signals.