For finding location of spikes in a time series I used to transform the data into wavelet space using

DiscreteWaveletPacketTransform [ data, filter, 0] 

and then shrink the basis using the universal threshold in Mathematica version 7 and now every single command, corresponding to wavelets, is changed in version 8.

Is there anybody who can tell me how can I do in version 8 again? I guess I need to use WaveletBestBasis command, but how?

  • $\begingroup$ From the docs it seems this function was not available in version 7. If you were using the Wavelet Explorer add-on in version 7, this guide should help in finding the equivalent commands. $\endgroup$
    – Szabolcs
    Commented Mar 9, 2012 at 14:24

2 Answers 2


After consulting a friend of mine P.M. I can tell you this. First of all as @Szabolcs @ruebenko already mentions - in order to get a comparison with Wavelet explorer (v7) to v8, you can go to the following link in the documentation center which shows how the syntax has changed:


For the problem at hand, if you want location of the spike, perhaps using continuous wavelet transform might give the result easily. Here is an example:

data = N@Table[Sin[4 \[Pi] t] + 2 Exp[-10^5 (1/3 - t)^2], {t, 0, 1, 0.001}];
cwd = ContinuousWaveletTransform[data, PaulWavelet[5], {8, 8}];
ws = WaveletScalogram[cwd, ColorFunction -> "AvocadoColors"];
posData = Abs[{3, 1} /. cwd[{3, 1}]];
positionOfSpike = Position[posData, Max[posData]];
Print["Spike is at  " <> ToString[positionOfSpike[[1, 1]]]]
Row[{ws, ListLinePlot[posData, PlotRange -> All]}]

enter image description here

However, for multiple spikes, he may have to make careful use of a local FindMaximum. Another useful thing is this:

data = N@Table[
    Sin[4 \[Pi] t] + 2 Exp[-10^5 (1/3 - t)^2], {t, 0, 1, 0.001}];
dwd = DiscreteWaveletPacketTransform[data, Automatic, 5];
 tmp = WaveletThreshold[
   WaveletBestBasis[dwd, {"Threshold", bestBasisThreshold}], {"Hard", 
 recon = InverseWaveletTransform[tmp];
 GraphicsRow[{ListLinePlot[recon, PlotLabel -> "Reconstruction"], 
   ListLinePlot[data - recon, PlotLabel -> "Error"]}, 
  ImageSize -> 500], {bestBasisThreshold, 0.001, 0.99, 
  Appearance -> "Labeled"}, {waveletThreshold, 0.001, 0.99, 
  Appearance -> "Labeled"}]

enter image description here

The manipulate above shows the interplay between wavelet best basis and wavelet threshold. For more information, we would recommend going to the documentation page:

WaveletBestBasis > Applications > Compressions.

and go through the examples.

  • $\begingroup$ Thank you Vitaliy but actually the stress in my question was on zero decomposition level, as seen DiscreteWaveletPacketTransform [data, filter, 0] $\endgroup$
    – K-1
    Commented Apr 24, 2012 at 4:35

Perhaps this helps:

(* data *)
data = Table[Sin[4 \[Pi] t] + RandomReal[0.1], {t, 0., 1, 1/2^9}];
data[[200]] = 1.5;

(* fourier based *)
dft = Fourier[data];
fdft = Chop[dft, 0.2];
ftdata = InverseFourier[fdft];

(* wavelet based *)
dwt = DiscreteWaveletTransform[data, DaubechiesWavelet[4]];
fdwt = WaveletThreshold[dwt];
wtdata = InverseWaveletTransform[fdwt];

Also, have a look at the upgrading tutorial: Compatibility/tutorial/WaveletExplorer


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.