Created
July 19, 2020 08:21
-
-
Save instance01/042733d8a6e6f2c4a01b6971eb3435c4 to your computer and use it in GitHub Desktop.
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
# Calculate uniform time warping (UTW) of two small time series. | |
# The arguably better alternative is dynamic time warping (DTW). | |
import numpy as np | |
X = np.array([3, 5, 9, 2, 3, 6, 3]) | |
Y = np.array([3, 4, 6, 10, 1, 3, 2, 7, 4]) | |
X_len = X.shape[0] | |
Y_len = Y.shape[0] | |
X = np.repeat(X, Y_len) | |
Y = np.repeat(Y, X_len) | |
utw = ((X - Y) ** 2).sum() / (X_len * Y_len) | |
print(utw) # ~3.60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment