# Measures to compute the similarity between two time series whose amplitude is periodic ignoring any phase differences

Question: Given two time series whose amplitudes are periodic, what measures could i use to quantify the similarity between them ignoring any phase difference?

Specifically, i am looking for measures to quantify the similarity between two time series whose amplitude is an angle (which is periodic) ignoring any differences in phase.

Below is an example of two such time series Notice that the two signals seem quite similar barring the phase difference

Approach so far

Since i want to ignore any phase differences between them, my idea was to compare their power spectrums. Shown below is an overlay of the power spectrums (also in log scale) of the two signals shown above.  Notice that their power spectra look quite similar. Would pearson's correlation be a good measure to quantify this similarity?

Another idea i have is to compute the cross-correlation of the two signals in time domain and use its maximum value to quantify their similarity ignoring phase.

But neither of these two approaches account for the periodic nature of the amplitude.

I believe that calculating the coherence would be of use to you.

The coherence at a frequency, $C_{XY}(f)$, between two series, $x(n)$ and $y(n)$, is defined as:

$C_{XY}(f) = \frac{|P_{XY}(f)|^2}{P_{X}(f)P_{Y}(f)}$

Where $P_X(f)$ and $P_Y(f)$ are the power spectrum of the series $x(n)$ and $y(n)$ respectively. $P_{XY}(f)$ is called the cross-spectrum.

Let's say that we calculate the spectrum of $x(n) = x_n$ by first Fourier transforming the windowed data:

$X(f) = \sum_{n=0}^{N-1}h_n x_n e^{-i2\pi fn}$

where $h_n = h(n)$ is the $n^{\text{th}}$ value of the window we are using. This implies that the power spectrum of $x(n)$ is:

$P_{X}(f) = |X(f)|^2$

The cross spectrum is then:

$P_{XY}(f) = |X(f) \cdot Y^{*}(f)|^{1/2}$, where $*$ denotes complex conjugate.

Thus, the coherence is:

$C_{XY}(f) = \frac{|X(f) \cdot Y^{*}(f)|}{|X(f)|^2 |Y(f)|^2}$.

After this, you could calculate the average coherence I suppose - I don't think averaging is the correct approach honestly, I will do some more checking. This is hopefully a start though.

Using a multitaper method for estimating your power spectra is a good idea (Spectrum Estimation and Harmonic Analysis, DJ Thomson, 1982 (paper) or Spectral Analysis for Physical Applications, Pervcival and Walden, 1993 (book)) as you are able to get a much reduced variance for your estimate.

If you decide to go that route, I would suggest checking out: http://www.spectraworks.com/Help/mtmtheory.html for more info.

• Sorry - I should mention that MATLAB has the function mscohere() for single window coherence and multitaper coherence can be calculated in R using the "multitaper" package. – driegert Mar 2 '15 at 23:08
• thank you for the suggestion. I landed on spectral coherence after some googling yesterday. Seems like a good way to go. But i feel uneasy about using it due to the nature of the amplitude (see y-axis in my plot of the signals in in time domain) of the two signals i am comparing. In my case the amplitude is an angle which is periodic. Another idea that i could use is to take the maximum value in the cross-correlation of the two signals in time domain. But it too doesnt account for periodic amplitude. – cdeepakroy Mar 2 '15 at 23:36
• changed the question to make things more clear – cdeepakroy Mar 3 '15 at 2:36
• It actually looks like the angle is constantly increasing (I don't see any points on the down slope). You could try removing the restriction of [0, 360) so you would have a constantly increasing process, remove a linear trend, estimate a spectrum of the residuals, compare those. – driegert Mar 7 '15 at 18:05
• @dreigert thanks for answering. I exactly did something very similar. What is plotted in the post is actually the instantaneous phase. So i unwrapped the phase, removed any shift, and compared them. I'll post my solution soon. – cdeepakroy Mar 8 '15 at 22:38