Created
April 27, 2022 07:08
-
-
Save darius-sas/9ad04922c8746f7c92976da842b94ad9 to your computer and use it in GitHub Desktop.
Dynamic Time Warping in R (DTW)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of using the dtw library | |
# This code is not mine. | |
library(dtw) | |
idx<-seq(0,6.28,len=100); | |
query<-sin(idx)+runif(100)/10; | |
t1 <- c(0, 0.5, 0) | |
t2 <- c(-1, 0, -1) | |
t3 <- c(-1, 0, 1) | |
t4 <- c(0, -0.5, 0) | |
a1 <- dtw(x = query, y = t1, keep = T) | |
a2 <- dtw(x = query, y = t2, keep = T) | |
a3 <- dtw(x = query, y = t3, keep = T) | |
a4 <- dtw(x = query, y = t4, keep = T) | |
plot(a1,type="twoway",offset=-2); | |
plot(a2,type="twoway",offset=-2); | |
plot(a3,type="twoway",offset=-2); | |
plot(a4,type="twoway",offset=-2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment