# When to use cross spectral density versus cross correlation?

All my life, I've used cross-correlation to analyze the strength of the relationship between an input signal and the output signal. I use this to determine which input signal most closely influences the output signal:

Yesterday, a friend told me that he uses cross spectral density (same as coherence, he say).

To my interpretation, they seem to quantify the same thing.

When would someone use one over the other?

• I believe the difference is the cross-correlation is in the time domain, while the cross spectral density is in the frequency domain. If I wanted to know how signals related to other signals versus time delay, I would use the cross-correlation function. If I wanted to know how signals related to other signals versus frequency, I would use cross spectral density. See this post as well: dsp.stackexchange.com/questions/10369/… Feb 26 '17 at 16:28
• I looked at the other source you posted a [link]. The answer by @forsker_for_dsp says "For Fourier who has as basis functions the sinusoid that extends infinite in time, power spectral density is the correct term. For wavelets, who has basis functions as finite in time deflections, we should use 'energy'." This doesn't make sense to me. If you use power for infinite signals, then you'd be dividing by infinity (because power is energy over time). Isn't it the other way around? Don't we want to use power for signals with finite support, and energy for signals with infinite support? Feb 26 '17 at 23:55
• It is because these are "densities" not total power; if you have the power spectral density and it was flat for example, the density is given in dBm/Hz (for a dB quantity of power), and we would need to multiply by the BW to get the total power. Feb 26 '17 at 23:59
• If you post this as a well-formed answer, i'll accept. thanks. Mar 2 '17 at 23:30

The cross-spectral density is in the frequency domain while the cross-correlation function is in the time domain. The two are Fourier Transform pairs, the FT of the cross correlation function is the cross-spectral density. The the two provide the same information, just that one is in the time domain and the other is in the frequency domain. This is just as the relationship between the auto-correlation function and power spectral density (power spectrum) for a signal which are also related as Fourier Transform pairs (as given by the Wiener- Khinchin theorem).

One common application of the cross-spectral density is finding the transfer function in a noisy system. We can cross correlate the input and output and assuming the signal is correlated but the noise is not (between input and output) we can optimally estimate the magnitude and phase response of the system.

One common application for cross-corrrelation is receiving GPS signals which at the antenna are up to 20 dB below the system noise floor! We cross correlate the extremely noisy signal received to the known pseudo-random noise sequences transmitted by the satellite and once correlated can extract the data messages and determine range to the satellites (and ultimately our position and time by triangulating on many satellites).

What you may also see is that we can do either approach in time or frequency- in the GPS example you can do the cross correlation I describe with FFT's given the relationship:

$$R_{xy}(\tau) = \text{ifft}(\text{fft}(x)\text{fft}^*(y))$$

Where:

$$R_{xy}(\tau)$$: Circular cross-correlation function.
$$\text{fft}(x)$$: The DFT of x.
$$\text{fft}^*(y)$$: The complex conjugate of the DFT of y.
$$\text{ifft()}$$: The inverse DFT

For an example with regards to GPS acquisition, see this MATLAB code I have posted on Mathwork's file exchange site.