dtw2vec {IncDTW} | R Documentation |
Fast vector-based Dynamic Time Warping
Description
Calculates the Dynamic Time Warping distance by hand of a vector-based implementation and is much faster than the traditional method dtw()
. Also allows early abandoning and sakoe chiba warping window, both for univariate and multivariate time series.
Usage
dtw2vec(Q, C, dist_method = c("norm1", "norm2", "norm2_square"),
step_pattern = c("symmetric2", "symmetric1"),
ws = NULL, threshold = NULL)
Arguments
Q |
Either Q is (a) a time series (vector or matrix for multivariate time series) or (b) Q is a cost matrix, so a matrix storing the local distances of the time series Q and C. If Q and C are matrices, they need to have the same number of columns. If Q is a cost matrix, C needs to be equal the character string "cm". |
C |
time series as vector or matrix, or for case (b) C equals "cm" |
dist_method |
character, describes the method of distance measure. See also |
step_pattern |
character, describes the step pattern. See also |
ws |
integer, describes the window size for the sakoe chiba window. If NULL, then no window is applied. (default = NULL) |
threshold |
numeric, the threshold for early abandoning. In the calculation of the global cost matrix a possible path stops as soon as the threshold is reached. Facilitates faster calculations in case of low threshold. The threshold relates to the non-normalized distance measure. (default = NULL, no early abandoning) |
Details
no matrices are allocated, no matrices are returned
Value
distance |
the DTW distance |
normalized_distance |
the normalized DTW distance, see also |
References
Leodolter, M.; Pland, C.; Brändle, N; IncDTW: An R Package for Incremental Calculation of Dynamic Time Warping. Journal of Statistical Software, 99(9), 1-23. doi: 10.18637/jss.v099.i09
Sakoe, H.; Chiba, S., Dynamic programming algorithm optimization for spoken word recognition, Acoustics, Speech, and Signal Processing [see also IEEE Transactions on Signal Processing], IEEE Transactions on , vol.26, no.1, pp. 43-49, Feb 1978. http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1163055
Examples
Q <- cumsum(rnorm(100))
C <- Q[11:100] + rnorm(90, 0, 0.5)
dtw2vec(Q = Q, C = C)
dtw2vec(Q = Q, C = C, ws = 30)
dtw2vec(Q = Q, C = C, threshold = 100)
dtw2vec(Q = Q, C = C, ws = 30, threshold = 100)
cm0 <- cm(Q, C)
dtw2vec(Q = cm0, C = "cm", ws = 30, threshold = 100)