I am trying to approximate a vector or a time series, in order to have as little changes as possible. To do so, I pretend to apply the Adaptive piecewise constant approximation (APCA) algorithm. Note: I can apply the PAA, but I prefer a method that allows different lengths for each segment of the approximated series.
The following paper Locally Adaptive Dimensionality Reduction for Indexing Large Time Series Databases (pages 196-199) claims to have found a faster alternative to APCA, based on wavelets, but I can’t figure out how to apply it in
The data used in the example is the following:
library(wavelets) x<-c(7, 5, 5, 3, 3, 3, 4, 6) w <- dwt(x, filter="haar",n.levels = 3)
I run the above code, but i haven't even found the same wavelet coefficients. I'll appreciate any help finding the same wavelet coefficients of the example, as well as the a final approximation.
According to the paper, the final solution seems to be the vector y, described as
Implementations of the original APCA algorithm can also be useful. Although
R code is preferred,
Python implementations are also welcome.