Learn R Programming

IncDTW (version 1.1.1)

dtw_dismat: DTW Distance Matrix

Description

Calculates a matrix of pairwise DTW distances for many multivariate time series, or a vector of DTW distances all relative to one query time series. A parallel computation is possible.

Usage

dtw_dismat(lot, dist_method = c("norm1", "norm2", "norm2_square"),
         step_pattern = c("symmetric2", "symmetric1"), normalize = TRUE,
         ws = NULL, threshold = NULL,
         return_matrix = TRUE, ncores = NULL, useRcppParallel = TRUE)

dtw_disvec(Q, lot, dist_method = c("norm1", "norm2", "norm2_square"), step_pattern = c("symmetric2", "symmetric1"), normalize = TRUE, ws = NULL, threshold = NULL, ncores = NULL)

Arguments

Q

time series, vector or matrix

lot

List of time series. Each entry of the list is a time series as described in dtw2vec.

dist_method

character, describes the method of distance measure. See also dtw.

step_pattern

character, describes the step pattern. See also dtw.

normalize

logical, whether to return normalized pairwise distances or not. If step_pattern == 'symmetric1' only non-normalized distances can be returned (default = TRUE)

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. (default = FALSE)

return_matrix

boolean, If TRUE (default) a symmetric matrix of differences is returned. If FALSE the distance matrix is returned as dist object.

ncores

integer, number of cores to be used for parallel computation of the distance matrix. If ncores = NULL (default) then ncores is set to the number of available cores minus 1. If ncores = 0 then no parallel computation is performed and standard sapply instead of parallel::parSapply is applied.

useRcppParallel

boolean, if the package RcppParallel (TRUE, default) or parallel (FALSE) is used for parallel computation

Value

input

the function input parameters

dismat

the matrix of pairwise DTW distances, either as matrix or dist object

disvec

the vector DTW distances

Details

no matrices are allocated, no matrices are returned

Examples

Run this code
# NOT RUN {
lot <- lapply(1:10, function(i){matrix(rnorm(100), ncol=2)})

# }
# NOT RUN {
# per default all minus 1 available cores are used
result <- dtw_dismat(lot = lot, dist_method = "norm2", ws = 20, 
                  return_matrix = FALSE)
# }
# NOT RUN {
# for few time series you can set ncores=0 for NON-parallel computation
result <- dtw_dismat(lot = lot, dist_method = "norm2", ws = 20, 
                  return_matrix = FALSE, ncores = 1)

# }

Run the code above in your browser using DataLab