distance_matrix_cpp: (C++) Distance Matrix of Two Time Series

View source: R/RcppExports.R

distance_matrix_cppR Documentation

(C++) Distance Matrix of Two Time Series

Description

Computes the distance matrix between the rows of two matrices y and x representing regular or irregular time series with the same number of columns. NA values should be removed before using this function. If the selected distance function is "chi" or "cosine", pairs of zeros should be either removed or replaced with pseudo-zeros (i.e. 0.00001).

Usage

distance_matrix_cpp(x, y, distance = "euclidean")

Arguments

x

(required, numeric matrix) univariate or multivariate time series.

y

(required, numeric matrix) univariate or multivariate time series with the same number of columns as 'x'.

distance

(optional, character string) distance name from the "names" column of the dataset distances (see distances$name). Default: "euclidean".

Value

numeric matrix

See Also

Other Rcpp_matrix: cost_matrix_diagonal_cpp(), cost_matrix_diagonal_weighted_cpp(), cost_matrix_orthogonal_cpp(), distance_ls_cpp()

Examples

#simulate two time series
x <- zoo_simulate(seed = 1)
y <- zoo_simulate(seed = 2)

#distance matrix
dist_matrix <- distance_matrix_cpp(
  x = x,
  y = y,
  distance = "euclidean"
)

distantia documentation built on April 4, 2025, 5:42 a.m.