# Magnitude-squared Coherence calculation inconsistence

I have to calculate the magnitude-squared coherence (MSC) between two signal. However, using a routine that uses only one taper (or no tapers at all) my result is always 1, despite the signals are clearly different. This doesn't happen if I use more than one taper. Searching a explication for this abnormal result, I come with a confusing characteristic of the MSC itself. The definition that I'm using is this

$$\gamma^2(\omega)=\frac{ |X(\omega)\overline{Y(\omega)}| ^2}{(X(\omega)\overline{X(\omega)}).(Y(\omega)\overline{Y(\omega)}) }$$

X and Y are the Fourier tranformed signals that depends on the frequency $\omega$. However, if you take any two complex numbers as the value of these functions in some fixed frequency, the result is always 1. Knowing that $|z|^2=z\overline{z}$ then

$$\gamma^2=\frac{(X\overline{Y})\overline{(X\overline{Y})} }{X\overline{X}Y\overline{Y}}=\frac{(X\overline{Y})(\overline{X}Y) }{X\overline{X}Y\overline{Y}}=\frac{X\overline{X}Y\overline{Y} }{X\overline{X}Y\overline{Y}}=1$$

Certainly there must be something I must be misunderstanding but I can't see what it is. Can anyone explain to me what is the catch?

Edit: I'm gonna use some matlab links as trustable sources. Definition of MS-coherence

http://www.mathworks.com/help/signal/ref/mscohere.html

definition of cross power spectral density

http://www.mathworks.com/help/signal/ref/cpsd.html

(the power spectral density is the " auto -cross" spectral density, i.e. the Fourier transform of the autocorrelation) A important property of the Fourier transform of the cross correlation can be found on wikipedia under "properties".

Another source can be found googling under the name "Coherence function in biomedical signal processing". Sorry i didn't post the direct links here, I don't have enough "reputation"

• It would help if you would include a reference to where you got your definition of $\gamma^2(\omega)$. Measures of coherence are generally based on the Cauchy-Schwarz Inequality which asserts that $$|\langle x,y\rangle |^2 \leq \langle x,x \rangle\cdot\langle y,y\rangle$$ with equality when $x = \lambda y$ where $\lambda$ is constant. In the context of coherence, equality is perfect coherence. But your $\gamma^2(\omega)$ is not quite the ratio of the two sides of the Cauchy-Schwarz Inequality. Jul 23, 2013 at 12:43
• Note the expectation operators in your definition of the coherence. You can't separate the $x$ and $y$ terms in the cross-spectral density in order to cancel with the denominator, as the expected value of their product is taken. Jul 23, 2013 at 16:05
• That's true. However I forgot to mention that i'm working with stationary random processes so the spectral densities and the correlation functions are Fourier tranform pairs. And the Fourier transform of the correlation functions can be written as the multiplication of the Fourier tranform of the individual functions (with one of the conjugated), as can be found in Wikipedia Jul 23, 2013 at 16:19
• The issue is that for random processes, it is not true that $X(\omega)$ and $Y(\omega)$ are the Fourier transforms of the processes (in fact, Fourier transform of a random process the way you seem to be thinking about it makes no sense whatsoever except as a complex-valued process) and that the crosspower spectral density $S_{X,Y}(\omega)$ equals $X(\omega)Y(\omega)$ and the power spectral density $S_X(\omega)$ is $|X(\omega)|^2 = X(\omega)X^*(\omega)$. Jul 23, 2013 at 19:43
• I'm not sure that I understand your definition of "random process". In signal processing a stationary random process "is a collection of time-history records having statistical properties that are invariant to translations of time" (from 'random data - analysis and measurement procedures'). In fact you can check as this concept is used to state some properties in the following link en.wikipedia.org/wiki/Spectral_density Jul 23, 2013 at 22:30

For any single chunk (window) of data the coherence will, as you observed, be 1. In order to properly estimate coherence you must average the spectra and cross-spectra for multiple windows, and THEN calculate coherence.

The auto-spectra XX and YY can be averaged the conventional way. For the cross-spectrum XY you must average the real and imaginary components first before calculating XY = sqrt( XY[imag]^2 + XY[real]^2 ).

Does that help? Averaging over 8 windows usually yields reliable estimates.

• Yep, that's the answer. Thank you very much John Sep 7, 2013 at 18:12
• Hi @John . A little question: Do you know the name of some book where I can read more about this? I haven't found a good one to study this on my own. Thx Sep 12, 2013 at 14:11

To expand on John's answer. Averaging over 8 windows may not enough to produce a reliable estimate for some applications.

According to the paper 1987 Coherence and Time Delay Estimation, G. Clifford Carter, the Magnitude squared coherence estimator suffers from bias and variance which can be minimized by using techniques such as :

• Hanning window for each segment
• Overlapping the segments at least 50%
• Increasing observation-time resolution-bandwidth product (increasing number of averages and frequency resolution of the DFT of each)
• If there is a time delay between the acquisition of the 2 signals to be used in the coherence, either we realign them before computing coherence or we make the ratio of the delay misalignment to the DFT size (before any zero padding) as small as possible (eq. 13b in the paper)

For instance I have felt confident enough about my magnitude squared coherence estimation by using similar parameters as in section 4.1.1 of 2011 Dynamic Testing of Data Acquisition Channels Using the Multiple Coherence Function, Troy C. Richards paper.