dtw_partial {IncDTW} | R Documentation |
Partial Dynamic Time Warping
Description
Get the cheapest partial open end alignment of two time series
Usage
dtw_partial(x, partial_Q = TRUE, partial_C = TRUE, reverse = FALSE)
Arguments
x |
|
partial_Q |
logical (default = TRUE), whether Q is aligned completely to C or open ended. |
partial_C |
logical (default = TRUE), whether C is aligned completely to Q or open ended. |
reverse |
logical (default = FALSE), whether Q and C are in original or reverse order. |
Details
Q is the time series that describes the vertical dimension of the global cost matrix, so length(Q)
is equal to nrow(x$gcm)
. So C describes the horizontal dimension of the global cost matrix, length(C)
is equal to ncol(x$gcm)
.
dtw_partial()
returns the open-end alignment of Q and C with the minimal normalized distance.
If partial_Q
and partial_C
both are TRUE
the partial alignment with the smaller normalized distance is returned.
If Q and C are in reverse order, then the optimal solution for the reverse problem is found, that is the alignment with minimal normalized distance allowing and open-start alignment.
Value
rangeQ |
Vector of initial and ending index for best alignment |
rangeC |
Vector of initial and ending index for best alignment |
normalized_distance |
the normalized DTW distance (see details in |
Examples
#--- Open-end alignment for multivariate time series.
# First simulate a 2-dim time series Q
Q <- matrix(cumsum(rnorm(50 * 2)), ncol = 2)
# Then simulate C as warped version of Q,
C <- simulate_timewarp(Q, stretch = 0.2, compress = 0.2,
preserve_length = TRUE)
# add some noise
C <- C + rnorm(prod(dim(C)))
# and append noise at the end
C <- rbind(C, matrix(rnorm(30), ncol = 2))
tmp <- dtw(Q = Q, C = C, ws = 50, return_QC = TRUE, return_wp = TRUE)
par <- dtw_partial(tmp, partial_C = TRUE)
par
plot(tmp, partial = par, type = "QC")
plot(tmp, partial = par, type = "warp")
plot(tmp, partial = par, type = "QC", selDim = 2)
#--- Open-start is possible as well:
Q <- sin(1:100)
C <- c(rnorm(50), Q)
tmp <- dtw(Q = rev(Q), C = rev(C))
dtw_partial(tmp, reverse = TRUE)