# How to Quantify a Difference in Spectral Information of two Signals?

As the title states, I am looking for established methods to quantify the difference in two FFTs. I have come across methods such as using cross correlation in the time domain or the coherence estimate of the power spectral density of two signals, but these methods seem more geared toward finding similarities in signals rather than differences.

I am running an experiment with a treatment and control group and I think the treatment is causing a change in some periodic motion which I am measuring optically and ultimately I want to quantify that change into a single number or metric.

I have thought of perhaps normalizing the FFTs of the two signals I am comparing and finding what frequency value is 50% of the area under the curve for the FFT. The idea being that if the peaks of the FFTs in my treatment group shift then so should the point of 50% of the area under the curve. But I'm not sure if this is a sensible approach.

Thanks for any assistance!

• Correlation equally finds similarities as well as differences. This sounds like what you would want to use for this. Mar 22 at 16:14
• Hi @DanBoschen, thanks for your comment. Can you be a bit more specific with what you mean? Maybe provide a link you have to this method? When I search for correlation equality all I find are things referring to the cross correlation which is not ideal since I want to compare signals of equal length. Mar 22 at 18:14
• thoughtco.com/… Mar 22 at 22:39

Quantifying a difference in the frequency domain can be useful if the information on how your signals differ is better expressed in the Fourier space. If this assertion is valid in your case, hereafter are hints on methodology, and basically the sort of you can find in Shazam to distinguish music from a short listening period.

By the way, I think that I have been trying to find an answer to a related question in 50% of my research hours pertaining to spectral or harmonic analysis (the rest was coding). I am not fully successful yet. I would however rephrase it as:

How could I easily find quantitative or selective (Fourier) features for relatively stationary signals?

By quantitative I mean that the feature set should be able to measure scalar values related (in a monotonic way) to a quantity I seek in the original signal. By separative I mean that features that could tell whether signals are "apart". Those two concepts could be related by proper distances or metrics between the feature sets of two signals.

In your proposal, there is a notion of location in the frequency axis, a sort of median of spectrum amplitudes : 50% of the area under the curve for the FFT. A notion of amplitude is skipped, as you may normalize spectra. There is no notion of uncertainty or spread either. I am often trying to consider, as first, feature triplets of Location-Amplitude-Spread ($$f^k_0,f^k_1,f^k_2$$) to describe the morphology of signals, spectra, or other suitable sparsifying transformations on signals.

Those three parameters could be compared to higher-order cumulants or moments of a distributions. They are related to integrals of the shape: $$M_d=∫^∞_{−∞}(t−c)df(t)dt$$ or their ratios. A related question is Finding the right measure to compare sound signals in the frequency domain.

As Dan says, correlation finds similarities as well as differences - the more similar, the less different.

The autocorrelations and cross-correlation of signals can be defined in the frequency domain as:

$$r_{xx}(k) = \mathbf{X}^H(k)\mathbf{X}(k)=\sum_{n=0}^{N-1} X^*(k;n)X(k;n) = ||\mathrm{X}(k)||^2$$

$$r_{xy}(k) = \mathbf{X}^H(k)\mathbf{Y}(k)=\sum_{n=0}^{N-1} X^*(k;n)Y(k;n)$$

where $$X(k;n)$$ is the STFT of the signal, $$k$$ is the discrete frequency and $$n$$ is the frame index. $$\mathbf{X}(k)$$ is the vector of frequency components of different frames.

The corss-correlation coefficient is defined as

$$\phi_{xy}(k) = \frac{r_{xy}(k)}{\sqrt{r_{xx}(k)r_{yy}(k)}} = \frac{\mathrm{X}^H(k)\mathrm{Y}(k)}{||\mathrm{X}(k)||\ ||\mathrm{Y}(k)||}$$

This metric is in the range of $$[0, 1]$$. As $$\phi_{xy}(k)\rightarrow 0$$, the greater the difference between $$x$$ and $$y$$ at the frequency $$k$$.