Learn R Programming

IncDTW (version 1.0.2)

idtw2vec: Dynamic Time Warping

Description

Wrapper function for the C++ calculations of vector based fast calculation of DTW. Allows incremental calculation for new observations and sakoe chiba warping window.

Usage

idtw2vec(Q, newObs, gcm_lc = NULL, nC = NULL, ws = NULL)

Arguments

Q

one dimensional vector, query time series.

newObs

one dimensional vector of new observations

gcm_lc

vector, last column of global cost matrix of previous calculation. If NULL, then DTW is calculated and the last column and last row are returned to start upcoming incremental calculations. (default = NULL)

nC

integer, is the length of the original time series C, of which newObs are the new observations. Length of time series C exclusive new observations, such that length(c(C,newObs)) = length(newObs) + nC. Necessary if ws is not NULL. (default = NULL)

ws

integer, describes the window size for the sakoe chiba window. If NULL, then no window is applied. (default = NULL)

Value

distance

the DTW distance

gcm_lc_new

the last column of the new global cost matrix

gcm_lr

the last row of the new global cost matrix

Details

no matrices are allocated, no matrices are returned

References

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

Run this code
# NOT RUN {
Q <- cumsum(rnorm(100))
C <- Q[11:100] + rnorm(90, 0, 0.5)

# initial calculation
res0 <- idtw2vec(Q=Q, newObs = C, gcm_lc = NULL)

# incremental calculation for new observations
res1 <- idtw2vec(Q, newObs = rnorm(10), gcm_lc = res0$gcm_lc_new)


# }

Run the code above in your browser using DataLab