I saw a beautiful application of wavelets applied to a randomly created data series of about 500 data points. It used the Haar wavelet and had two sliders. The first slider allowed the user to view a smooth transition from the most coarse Haar approximation to the most refined. The second allowed the user to progressively detrend the data. Both can be used together. The application did not show the code. It is clear to me that manipulate was used to creat the sliders, but that's all I can get from it as a new user of Mathematica. I'm not sure how to create these sliders for this application (i.e., how to access the individual waveforms that when added together reconstruct the data). I have used manipulate with sliders successfully for other applications, such as for approximating a price series with a log periodic cosine function.

  • 1
    $\begingroup$ And the question is ... $\endgroup$ Jan 1, 2015 at 12:42
  • $\begingroup$ Maybe browse some of the results of this: ?*Wavelet* and try to ask a specific question. $\endgroup$
    – bill s
    Jan 1, 2015 at 13:46
  • $\begingroup$ Point us to the demonstration (online?) and we'll try to generate code that would produce it. $\endgroup$ Jan 1, 2015 at 17:55
  • 1
    $\begingroup$ David, here is the source of my question:youtube.com/watch?v=PUUSMXdBdTQ&spfreload=10 $\endgroup$
    – jrabbit
    Jan 2, 2015 at 14:05
  • $\begingroup$ Sjoerd, I did a fair amount of research as you mention. I thought I could just add a parameter inside the brackets of HaarWavelet(),and add a range of values, say .001 to .99, using manipulate, but I really don't no how to "get inside" the HaarWavelet function to do this. I didn't find that the documentation for wavelets aided me with this, though I copied, pasted, and attempted to modify code from Wolfram demonstrations. I've also made an effort to understand the underlying math of the Haar wavelet in particular. $\endgroup$
    – jrabbit
    Jan 2, 2015 at 14:17

1 Answer 1


I won't catch the fish for you rather than teach you how to do it.

Generate a random data set:

data = LowpassFilter[Accumulate@Re@Fourier[Table[RandomReal[{-.5, .5}] 
          Sinh[Exp[RandomReal[{-.5, .5}]^2]], {2^10}]], .4];

Mathematica graphics

and transform it

dwd = DiscreteWaveletTransform[data, HaarWavelet[]]
swd = StationaryWaveletTransform[data, HaarWavelet[]]

We will compare two different ways to detrend the set

ListLinePlot[data - .93 (Last[swd[Automatic, "Values"]])[[1]]]

Mathematica graphics

The coefficient .93 is sometimes used when correcting the background drift in analytical chemistry, but feel free to experiment.

And now the other one

ListLinePlot@InverseWaveletTransform[WaveletMapIndexed[#1 0.0 &, dwd, {___, 0}]]

Mathematica graphics

You mentioned that you need to see the different approximations (levels) of the transform.

Manipulate[ListLinePlot[dwd[{HaarApproximation}, "Values"]],
              {HaarApproximation, First /@ dwd[{___, 0}]}]

enter image description here

  • $\begingroup$ +1 for answering a question which has not yet been asked :-) $\endgroup$
    – chris
    Jan 1, 2015 at 19:23
  • $\begingroup$ @chris Appreciate it :) $\endgroup$
    – Sektor
    Jan 1, 2015 at 19:36
  • $\begingroup$ Sektor, many thanks for your impressive response! I can see that I have a lot to learn in Mathematica syntax. See the URL above where I got the inspiration to try this. You can see how the video is using sliders. I tried to contact the author to see if he would give me his code but had no luck contacting him (no email address). I tried cutting and pasting from several Wolfram demonstrations with no success. My understanding from stock trading is that the detrending means giving the data a mean of zero. $\endgroup$
    – jrabbit
    Jan 2, 2015 at 14:11
  • $\begingroup$ No worries, I love working with wavelets :) Don't be afraid of the learning curve it is really not that horrible :D To get a mean closer to 0 you can just do this data - Mean[data]. Of course when working with wavelets you can be more precise when you de-trend. $\endgroup$
    – Sektor
    Jan 2, 2015 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.