mass_weighted: Calculates the distance profile using MASS_WEIGHTED algorithm

View source: R/mass_weighted.R

mass_weightedR Documentation

Calculates the distance profile using MASS_WEIGHTED algorithm

Description

Mueen's Algorithm for Similarity Search is The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance and Correlation Coefficient.

Usage

mass_weighted(
  query_window,
  window_size,
  data_fft,
  data_size,
  data_mean,
  data_sd,
  data_pre,
  weight,
  ...
)

Arguments

query_window

a vector of numeric. Query window.

window_size

an int. Sliding window size.

data_fft

precomputed data product.

data_size

an int. The length of the reference data.

data_mean

precomputed data moving average.

data_sd

precomputed data moving standard deviation.

data_pre

precomputed weighted data product.

weight

a vector of numeric with the same length of the window_size.

...

just a placeholder to catch unused parameters.

Value

Returns the distance_profile for the given query and the last_product for STOMP algorithm.

References

  • Abdullah Mueen, Yan Zhu, Michael Yeh, Kaveh Kamgar, Krishnamurthy Viswanathan, Chetan Kumar Gupta and Eamonn Keogh (2015), The Fastest Similarity Search Algorithm for Time Series Subsequences under Euclidean Distance

Website: https://www.cs.unm.edu/~mueen/FastestSimilaritySearch.html

See Also

mass_pre_w() to precomputation of input values.

Examples

w <- mp_toy_data$sub_len
ref_data <- mp_toy_data$data[, 1]
query_data <- mp_toy_data$data[, 1]
weight <- c(
  rep(1, mp_toy_data$sub_len / 3), rep(0.5, mp_toy_data$sub_len / 3),
  rep(1, mp_toy_data$sub_len / 3)
)

pre <- tsmp:::mass_pre_w(ref_data, query_data, w, weight)

dp <- list()
for (i in 1:(pre$data_size - w + 1)) {
  dp[[i]] <- tsmp:::mass_weighted(
    query_data[i:(i - 1 + w)], pre$window_size, pre$data_fft, pre$data_size,
    pre$data_mean, pre$data_sd, pre$data_pre, pre$weight
  )
}

tsmp documentation built on Aug. 21, 2022, 1:13 a.m.