I have a multidimensional time series on which I would like to perform some clustering. I have been looking at DTW as a distance metric since my series are not always aligned in time. The problem I have is that while the one to many mapping of points along two series allows for their alignment in the event they are the same signal but just shifted in time, it also means that time series with different frequencies are treated as being similar. In this case, a different frequencey should result in a larger distance metric. I can impose some locality constrains using different warping windows but that does not really help. Is there such a time series similarity measure that aligns series that are shifted in phase but treats differences in frequencies between series as being different?


In this case the time series corrsoponds to small molecule vibrational motion. Each of the dimensions in the time series corrosponds to a different bond length or angle and they are inherently coupled. Below are two example 1D cuts of the higher dimensional time series (prior to Z-normalisation).

Dimension 1 - a bond length Dimension 2 - an angle.

So far I have just been playing with a single dimension (the first plot above), and the standard symmetric step used in DTW results in a measure that is not physical for my system, for example different frequency vibrations are treated as being similar. Let us take several of the smaller amplitude and higher frequencey signals from the first plot as an example,

example subseries

Using the symmetric step, the series labelled 0 and 2 are predicted to have a much lower alignment cost than the others. Here several of the points in the first peak of the querry value is matched to many points in the lower frequency signal. By allowing many horizontal/ vertical steps in the construction of the warping path, one ignores differences in frequency.

Symmetric step pattern for two signals of diff freq

I then looked at different step patterns, and by restricting the freedom for horizontal/ verticle steps through one of the Rabiner Juang type patterns, I achieve a more sensible result,

RJ type pattern warping

here you can see that the one to many mapping of the points in the querry to the lower frequency series no longer exists. It seems that using such a step pattern enforces the warping behaviour I want - basically it just shifts the two signals along eachother as to optimally align them. When testing it on other combinations of signals from the series I have, it ranks them as one would expect now. My only concern now is the treatment of the end points. Perhaps I can allow some horizontal and vertical steps but restrict the number of succesive steps.

Another problem is Z-normalisation. Currently I perform this once for the time series, not for each sequence, else the ampltiude of the series shift with respect to eachother? In this case the amplitude of the raw signal matters and should be treated differently. Perhaps DTW is not the measure I need, within this application to physics different frequencies and ampltidues in the time series corrospond to the molecular system having different energies and being in a different state and therefore they must be treated differently.

  • $\begingroup$ Please don't use "EDIT:". Instead revise the question so it reads well for someone who encounters this for the first time. See cs.meta.stackexchange.com/q/657/755. Please ask only one question per post. $\endgroup$
    – D.W.
    Commented Aug 3, 2022 at 16:46
  • $\begingroup$ Your signals seem essentially aperiodic, so why do you discuss frequencies ? $\endgroup$
    – user16034
    Commented Aug 4, 2022 at 13:27
  • $\begingroup$ What is your question, in fact ? $\endgroup$
    – user16034
    Commented Aug 4, 2022 at 13:30

1 Answer 1


Minor point, you say "looking at DTW as a distance metric " DTW is not a metric, it is just a measure.

The answer to your question "Is there such a time series similarity measure that aligns series that are shifted in phase but treats differences in frequencies between series as being different" is Yes.

You can use phase invariant distance ([a] page 3). If you need speed, you can compute this in just O(nlog(n)).

Having said that, I am not convinced this is what you need.

Can you show examples of the data? That way I could advise you.

At a minimum, I recommend you read [a] and https://www.cs.unm.edu/~mueen/DTW.pdf

[a] https://www.cs.ucr.edu/~eamonn/Complexity-Invariant%20Distance%20Measure.pdf

  • $\begingroup$ Thanks for sharing these references and your help, I have provided some examples as an edit. $\endgroup$
    – Kyle
    Commented Jul 4, 2022 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.