1

I'm trying to approximate a time series/vector usind dwt. I can apply the full dwt and idwt reconstruction, but i don´t know how to reconstruct/approximate the original signal based on just a few coefficients (not all).

I tryed this:

library(wavelets)
x<-c(7, 5, 5, 3, 3, 3, 4, 6)
w <- dwt(x, filter="haar",n.levels = 3)
rec<-idwt(w)

I read about coefficient truncation, but I don´t know how to do it.

What if I need an approximation based on ,lets say, 2 coefficients?

I'll appreciate any help.

Nelson
  • 301
  • 3
  • 15

1 Answers1

1

In between lines 3 and 4 you can do

str    (w)     # see what w looks like
w@W$W1 []  = 0 # set the 1st level detail coefficients to 0 

then your rec will be

[1] 6 6 4 4 3 3 5 5

and that makes sense: without detail coefficients on the finest level the Haar transform returns the average of each pair of points, for both points.

alle_meije
  • 2,424
  • 1
  • 19
  • 40