# Intuitive explanation of coherence

I am a biologist so apologies for the basic question.

I am trying to get an intuitive understanding of what the coherence between 2 signals actually means. I have read a couple of introductory texts and an idea that keeps coming up is that (roughly) two signals are coherent if you can accurately predict the phase of one given the phase of the other (i.e. if there is a constant phase difference).

But I am getting confused when it comes to thinking about coherence with regards to a particular frequency. It feels like any wave at a particular frequency will have a constant phase difference relative to all waves with the same frequency, but from the explanation in the paragraph above that would mean that coherence should be 1 across every frequency for every signal. I am definitely fundamentally misunderstanding this, if someone could please explain where I'm going wrong that would be very much appreciated!

Sorry again for asking something so simple, I am very new to this!

It feels like any wave at a particular frequency will have a constant phase difference relative to all waves with the same frequency, but from the explanation in the paragraph above that would mean that coherence should be 1 across every frequency for every signal.

I think you're falling into the frequency-domain trap. The frequency domain is nice, but it was invented to use when thinking in the time domain is harder. If thinking in the time domain is easier -- don't try to wedge things into the frequency domain, unless you have to for some other part of the problem.

So if you have two signals that are predominantly sinusoidal, and if they're both frequency modulated, then you'll have something like $$s_n(t) = \cos\left( \int \omega_n(t) dt\right)$$ where $$\omega_n(t)$$ is a random process. If $$\omega_1(t)$$ exactly equals $$\omega_2(t)$$ then your signals will be coherent -- even if $$\omega_1$$ and $$\omega_2$$ are time-varying. If $$\omega_1(t)$$ and $$\omega_2(t)$$ have equal long-term averages, but small differences at any given time, then your signals will show some coherence (depending on how you assign numbers to "small differences" and "some coherence"). If $$\omega_1(t)$$ and $$\omega_2(t)$$ are unrelated, then your signals will have no coherence.

But note: this is really flipping hard to analyze in the frequency domain and not too bad to think about in the time domain. So thank M. Fourier for all his hard work, do this analysis in the time domain, and then use the frequency domain the next time you really need it.

I think your understanding in first paragraph is correct. When two signals are coherent, they are 'locked' in phase. The phase of one signal tracks the other.

A signal $$x(t)$$ can be written as a composite of different single frequency waves (Fourier synthesis). $$x(t) = \int X(f)e^{j2\pi ft}$$. Imagine another signal whose fourier transform is $$X_1(f) = X(f)e^{j\phi}$$. Each frequency of second signal is having constant phase difference with respect to first signal. In this case, $$x_1(t) = \int X_1(f)e^{j2\pi ft} =\int X(f)e^{j\phi}e^{j2\pi ft} = e^{j\phi}\int X(f)e^{j2\pi ft} = e^{j\phi}x(t)$$ having a constant phase difference with respect to $$x(t)$$. So coherence between two signals will also imply each of the signal frequencies are also coherent.

Coherence is a statistical measure that shows the degree that two ergodic signals are related through a linear process (non-linearities and additional noise sources will decrease coherence). It is a real quantity with values between 0 and 1 (where 1 means one signal can be completely established from the other through a linear filter). It is found by the ratio of the cross power spectral density divided by the individual power spectral densities as:

$$C = \frac{|S_{xy}(\omega)|^2}{S_{xx}(\omega)S_{yy}(\omega)}$$

Where $$C$$: Coherence

$$S_{xx}(\omega)$$: Power spectral density of signal $$x(t)$$

$$S_{yy}(\omega)$$: Power spectral density of signal $$y(t)$$

$$S_{xy}(\omega)$$: Cross power spectral density between two signals $$x(t)$$ and $$y(t)$$

Consider a simple case where the $$y(t)$$ is completely defined by the input $$x(t)$$ passed through a linear transversal system (filter) with impulse response $$h(t)$$: $$y(t) = x(t)\star h(t)$$

Where $$\star$$ is the convolution operator. Here the output is the weighted sum of multiple weighted delays of the input, so visually in time $$x(t)$$ and $$y(t)$$ could look drastically different. However given this linear relationship specifically, and that there are no other noise sources or other signals introduced that are independent between the two, the coherence will be 1! That is exactly what coherence is, the degree that this holds, and it simply means that there is a least squared solution to make a filter such that we can recover x(t) from y(t) alone (so coherence gives us a measure of how effective a linear equalizer can be).

Here we see how it the coherence = 1 in this case using the formula above:

Given that: $$S_{xy}(\omega) = H(\omega)S_{xx}(\omega)$$

$$S_{yy}(\omega) = |H(\omega)|^2S_{xx}(\omega)$$

The coherence is computed to be:

$$C = \frac{|S_{xy}(\omega)|^2}{S_{xx}(\omega)S_{yy}(\omega)}= \frac{|H(\omega)|^2S_{xx}(\omega)^2}{S_{xx}(\omega)|H(\omega)|^2S_{xx}(\omega)} = 1$$

Coherence is not to be confused with correlation which is another statistical measure of similarity showing directly the linear dependence on a sample by sample basis of input and output. Correlation is given in forms similar to below where we have a sum of conjugate products or integration of conjugate products for the discrete and continuous time domain respectively:

$$corr[n] = \sum x[n]y^*[n]$$ $$corr(t) = \int x(t)y^*(t)dt$$

Correlation and Coherence are related in that the cross power spectral density is the Fourier Transform of the cross-correlation function of x(t) and y(t), which does the correlation function above repeatably for different time delays between x an y:

$$R_{xy}(\tau) = \int x(t)y^*(t-\tau)dt$$