1
$\begingroup$

I have been reading this PhD theis about wavelets and I am trying to reproduce some of the results but I don't know the specific code to use to generate similar results.

The original time series looks like this: enter image description here

Then, the paper says:

The customer demand is transformed to the wavelet domain by the non-decimated wavelet transform performed with the Symmlet 8 filter. Figure 47 shows customer demand in the wavelet domain.

enter image description here

Can someone point me out how to reproduce this results using Python (then R, then matlab, in that order of preference)

NOTE: link to document, page 122: A Multiscale Forecasting Methodology for Power Plant Fleet Management A Thesis, Hongmei Chen, Feb. 2005.

$\endgroup$
1
$\begingroup$

With a fake imitation of your data, here is a first try in Matlab, which I may improve later on. It uses the stationary wavelet transform swt.m:

nSample = 256;
timeOnset = 25;

time = linspace(1,nSample,nSample)';
%ramp = max(time,timeOnset)/nSample;
ramp = abs(time-timeOnset)/nSample;

nLevel1 = 4;
nLevel2 = 5;
waveletName = 'sym8';
data = 0.15*((1+rand(nSample,1)/1).^0.5).*sin(2*pi*time/nSample*42)+0.65*(ramp+1);
dataSWT1 = swt(data,nLevel1,waveletName);
dataSWT2 = swt(data,nLevel2,waveletName);
subplot(3,1,1);
plot(time,data);axis tight
subplot(3,1,2);
imagesc(dataSWT1);axis tight
xlabel([num2str(nLevel1),' levels'])
subplot(3,1,3);
imagesc(dataSWT2);axis tight
xlabel([num2str(nLevel2),' levels'])

data and stationary wavelet transform

| improve this answer | |
$\endgroup$
  • $\begingroup$ thanks this is great! Short follow-up Q, the 4-level and 5-level wavelet plots plot the detail coefficients, am I right? How did you select those since I see in your code dataSWT1 = swt(data,nLevel1,waveletName); which in my mind contains both, the approximation and the detail coefficients. $\endgroup$ – Dnaiel Aug 27 '18 at 18:47
  • 1
    $\begingroup$ I was mistaken by the paper notations. To me, 1-level splits data into 2 subbands: one for the approximation, one for the details. 2-level splits the former approximation into 2 subbands: one for the second-level approximation, one for the second-level details. So to reproduce the paper, you should use 3-level and 4-level in my code. The blueish bands are details. The green-yellow is approximation. To select details only, skip the last row: dataSWT1(1:end-1,:). $\endgroup$ – Laurent Duval Aug 27 '18 at 19:56

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