binary2tau function

Convert changepoint sets to binary strings

Convert changepoint sets to binary strings

binary2tau(x) tau2binary(tau, n)

Arguments

  • x: A binary string that encodes a changepoint set. See GA::gabin_Population().
  • tau: a numeric vector of changepoint indices
  • n: the length of the original time series

Returns

  • binary2tau(): an integer vector

  • tau2binary(): an integer vector of length n

Details

In order to use GA::ga() in a genetic algorithm, we need to encoude a changepoint set as a binary string.

binary2tau() takes a binary string representation of a changepoint set and converts it into a set of changepoint indices.

tau2binary() takes a set of changepoint indices the number of observations in the time series and converts them into a binary string representation of that changepoint set.

Examples

# Recover changepoint set indices from binary strings binary2tau(c(0, 0, 1, 0, 1)) binary2tau(round(runif(10))) # Recover binary strings from changepoint set indices tau2binary(c(7, 17), n = 24) tau2binary(binary2tau(c(0, 0, 1, 1, 0, 1)), n = 6)