auto_sum_path_cpp: (C++) Sum Distances Between All Consecutive Samples in the...

View source: R/RcppExports.R

auto_sum_path_cppR Documentation

(C++) Sum Distances Between All Consecutive Samples in the Least Cost Path Between Two Time Series

Description

Computes the cumulative auto sum of auto-distances of two time series for the coordinates of a trimmed least cost path. The output value is used as normalization factor when computing dissimilarity scores.

Usage

auto_sum_path_cpp(x, y, path, 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'.

path

(required, data frame) least-cost path produced by cost_path_orthogonal_cpp(). Default: NULL

distance

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

Value

numeric

See Also

Other Rcpp_auto_sum: auto_distance_cpp(), auto_sum_cpp(), auto_sum_full_cpp(), subset_matrix_by_rows_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"
)

#least cost matrix
cost_matrix <- cost_matrix_orthogonal_cpp(
  dist_matrix = dist_matrix
)

#least cost path
cost_path <- cost_path_orthogonal_cpp(
  dist_matrix = dist_matrix,
  cost_matrix = cost_matrix
)

nrow(cost_path)

#remove blocks from least-cost path
cost_path_trimmed <- cost_path_trim_cpp(
  path = cost_path
)

nrow(cost_path_trimmed)

#auto sum
auto_sum_path_cpp(
  x = x,
  y = y,
  path = cost_path_trimmed,
  distance = "euclidean"
)

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