Skip to content

Dynamic Time Warping (DTW) to find dynamic lags between 2 time series

Notifications You must be signed in to change notification settings

hashim-vgr/dtw-showing-dynamic-lags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dtw-showing-dynamic-lags

DTW is a method to quantify the similarity between two time series or sequences exhibiting a certain likeness but may vary in speed and amplitude.

DTW can be used to calculate the similarites between 2 times series.

But here i'm showing how to use it to calculate the dynamic lags between two time series signals.

what are dynamic lags?

image
Like the image shown above, dynamic lags give information on wether a current sample is leading of lagging correspoinding to it's counterpart in the other signal.

detailed breadown of the process

step 1: take 2 signals with same number of samples (s1.txt and s2.txt in the code provided)

image

step 2: calculate error matrix with a defined search window (given as 100 in the code)

image
image

step 3: accumulated the errors by an interval of H (value set as 50 in the code)

image
image

step 4: backtrack through the accumulated indices to get dynamic lags

image
the red arrow shows the way we backtrack

step 5: interpolate the lag waveform to the same number as our number of samples

image
this wave form means: 1. For positive values of lag waveform, signal 1 is leading in respect to signal 2 2. For negative values of lag waveform, signal 1 is lagging in respect to signal 2

Happy coding...!!!

About

Dynamic Time Warping (DTW) to find dynamic lags between 2 time series

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages