# Similarity of two discrete fourier tranforms?

In climate modelling, you're looking for a models that can adequately portray the Earth's climate. This includes showing patterns that are semi-cyclical: things like the El Nino Southern Oscillation. But model verification occurs generally over relatively short time periods, where there is decent observational data (last ~150 years). This means that your model could be displaying the right patterns, but be out of phase, such that linear comparisons, like correlation, will not pick up that the model is performing well..

Discrete Fourier transforms are commonly used to analyse climate data (here's an example), in order to pick up such cyclic patterns. Is there any standard measure of the similarity of two DFTs, that could be used as a verification tool (ie. a comparison between the DFT for the model, and the one for the observations)?

Would it make sense to take the integral of the minimum of the two area-normalised DFTs (using absolute real values)? I think this would result in a score $x\in[0,1]$, where $x=1\implies$ exactly the same patterns, and $x=0\implies$totally different patterns. What might the drawbacks of such a method be?

• Have you looked into using coherence (in the signal processing sense, not the statistical), a cross-spectral measure? I'm not sure if that's the type of measurement that you're looking for. – jonsca Aug 8 '12 at 2:15
• @jonsca: Interesting stuff. I'm certainly not looking for causality, but I can see how it might be useful. The example on that wikipedia page is a bit weird (why doesn't it include barometric pressure as a model variable?). Also, I'm not sure where the 90% figure comes from... – naught101 Aug 8 '12 at 2:25
• That's a good question. That example has been added to the article since the last time I read it. I suspect it might have to do with the coherence being centered on the per day and per 2 day frequencies (therefore tied to a daily tidal phenomenon), but that's just a guess... – jonsca Aug 8 '12 at 2:35
• (I don't know if they integrated to find that 90%, though) – jonsca Aug 8 '12 at 2:42

## 3 Answers

Spectral coherence, if used correctly would do it. Coherence is computed at each frequency-and hence is a vector. Hence, a sum of a weighted coherence would be a good measure. You would typically want to weight the coherences at frequencies that have a high energy in the power spectral density. That way, you would be measuring the similarities at the frequencies that dominate the time series instead of weighting the coherence with a large weight, when the content of that frequency in the time series is negligible.

So, in simple words- the basic idea is to find the frequencies at which the amplitude(energy) in the signals are high(interpret as the frequencies that dominantly constitute each signal) and then to compare the similarities at these frequencies with a higher weight and compare the signals at the rest of the frequencies with a lower weight.

The area which deals with questions of this kind is called cross-spectral analysis. http://www.atmos.washington.edu/~dennis/552_Notes_6c.pdf is an excellent introduction to cross-spectral analysis.

Optimal Lag: Also look at my answer over here: How to correlate two time series, with possible time differences

This deals finding the optimal lag, using the spectral coherence. R has functions to compute the power spectral densities, auto and cross correlations, Fourier transforms and coherence. You have to right code to find the optimal lag to obtain the max. weighted coherence. That said, a code for weighting the coherence vector using the spectral density must also be written. Following which you can sum up the weighted elements and average it to get the similarity observed at the optimal lag.

• That's an excellent resource! It deals with hypothesis testing nicely, which a lot of material on coherence conveniently avoids – jonsca Aug 21 '12 at 13:01

Have you tried another approach for climate signal detection/modelling, like a wavelet analysis? The big problem that can arise with the DFT in climate analysis is actually what you mention: the oscillations are not perfectly periodic and they usually have different time spans so they can actually have many different oscillation ranges, which is pretty confusing from a Fourier Transform perspective.

A wavelet analysis is more suitable to climate signals because they allow you to check different time spans of oscillation; just as different frequencies are played at different times by a musical instrument, you can check different frequencies in different time spans with the wavelet transform.

If you are interested, this paper by Lau & Weng (1995) should erase most of your doubts about this method. The most interesting part is that the wavelet transform of a model versus that of the data are almost directly comparable, because you can directly compare the time span that your model predicts, leaving out all of the spurious oscillation ranges that it doesn't.

PS: I have to add that I wanted to post this as a comment, because it is not actually what the OP's is asking for, but my comment would have been too large and decided to post it as an answer that might come in handy as an alternative approach to that of DFT's.

I voted for and second the use of wavelet and spectrogram based analysis as an alternative to dft. If you can decompose your series into localized time-frequency bins, it reduces the fourier problems of aperiodicity and non-stationarity, as well as provides a nice profile of discretized data to compare.

Once the data is mapped to a three dimensional set of spectral energy vs. time and frequency, euclidean distance can be used to compare profiles. A perfect match would approach the lower bound distance of zero.* You can look into time series data mining and speech recognition areas for similar approaches.

*note that the wavelet binning process will filter the information content somewhat- If there can be no loss in the compared data, it might be more suitable to compare using euclidean distance in the time domain