Coherence Function

A function related to cross-correlation is the coherence function, defined in terms of power spectral densities and the cross-spectral density by

$\displaystyle C_{xy}(\omega) \isdef \frac{\vert R_{xy}(\omega)\vert^2}{R_x(\omega)R_y(\omega)}.

In practice, these quantities can be estimated by time-averaging $ \overline{X(\omega_k)}Y(\omega_k)$, $ \left\vert X(\omega_k)\right\vert^2$, and $ \left\vert Y(\omega_k)\right\vert^2$ over successive signal blocks. Let $ \{\cdot\}_m$ denote time averaging across frames as in Eq.$ \,$(8.3) above. Then an estimate of the coherence, the sample coherence function $ {\hat
C}_{xy}(\omega_k)$, may be defined by

$\displaystyle {\hat C}_{xy}(\omega_k) \isdef
...\vert^2\right\}_m\cdot\left\{\left\vert Y_m(\omega_k)\right\vert^2\right\}_m}.

Note that the averaging in the numerator occurs before the absolute value is taken.

The coherence $ C_{xy}(\omega)$ is a real function between zero and one which gives a measure of correlation between $ x$ and $ y$ at each frequency $ \omega$. For example, imagine that $ y$ is produced from $ x$ via an LTI filtering operation:

$\displaystyle y = h\ast x \;\implies\; Y(\omega_k) = H(\omega_k)X(\omega_k)

Then the magnitude-normalized cross-spectrum in each frame is

{\hat A}_{x_m y_m}(\omega_k) &\isdef &
= \frac{H(\omega_k)}{\left\vert H(\omega_k)\right\vert}

so that the coherence function becomes

$\displaystyle \left\vert{\hat C}_{xy}(\omega_k)\right\vert^2 =
\left\vert\frac{H(\omega_k)}{\left\vert H(\omega_k)\right\vert}\right\vert^2 = 1.

On the other hand, when $ x$ and $ y$ are uncorrelated (e.g., $ y$ is a noise process not derived from $ x$), the sample coherence converges to zero at all frequencies, as the number of blocks in the average goes to infinity.

A common use for the coherence function is in the validation of input/output data collected in an acoustics experiment for purposes of system identification. For example, $ x(n)$ might be a known signal which is input to an unknown system, such as a reverberant room, say, and $ y(n)$ is the recorded response of the room. Ideally, the coherence should be $ 1$ at all frequencies. However, if the microphone is situated at a null in the room response for some frequency, it may record mostly noise at that frequency. This is indicated in the measured coherence by a significant dip below 1. An example is shown in Book III [69] for the case of a measured guitar-bridge admittance. A more elementary example is given in the next section.

Coherence Function in Matlab

In Matlab and Octave, cohere(x,y,M) computes the coherence function $ C_{xy}$ using successive DFTs of length $ M$ with a Hanning window and 50% overlap. (The window and overlap can be controlled via additional optional arguments.) The matlab listing in Fig.8.14 illustrates cohere on a simple example. Figure 8.15 shows a plot of cxyM for this example. We see a coherence peak at frequency $ 0.25$ cycles/sample, as expected, but there are also two rather large coherence samples on either side of the main peak. These are expected as well, since the true cross-spectrum for this case is a critically sampled Hanning window transform. (A window transform is critically sampled whenever the window length equals the DFT length.)

Figure 8.14: Coherence measurement example in matlab.

% Illustrate estimation of coherence function 'cohere'
% in the Matlab Signal Processing Toolbox
% or Octave with Octave Forge:
N = 1024;           % number of samples
x=randn(1,N);       % Gaussian noise
y=randn(1,N);       % Uncorrelated noise
f0 = 1/4;           % Frequency of high coherence
nT = [0:N-1];       % Time axis
w0 = 2*pi*f0;
x = x + cos(w0*nT); % Let something be correlated
p = 2*pi*rand(1,1); % Phase is irrelevant
y = y + cos(w0*nT+p);
M = round(sqrt(N)); % Typical window length
[cxyM,w] = cohere(x,y,M); % Do the work
figure(1); clf;
stem(w/2,cxyM,'*'); % w goes from 0 to 1 (odd convention)
legend('');         % needed in Octave
grid on;
xlabel('Normalized Frequency (cycles/sample)');
axis([0 1/2 0 1]);
replot;  % Needed in Octave
saveplot('../eps/coherex.eps'); % compatibility utility

Figure 8.15: Sample coherence function.

Note that more than one frame must be averaged to obtain a coherence less than one. For example, changing the cohere call in the above example to ``cxyN = cohere(x,y,N);'' produces all ones in cxyN, because no averaging is performed.

Next Section:
Recommended Further Reading
Previous Section:
Power Spectral Density Estimation