You will need the executables ~p6730/exercises/wavelets/wavelet and some data files in ~p6730/exercises/wavelet. We also use ~p6730/exercises/fft/makeft. The handout Discrete Wavelet Transforms may help.
(5,-1,2,0)
This is the same example as given in the handout. To simplify the
arithmetic, use the basis functions discussed in class (and the
handout) with 1's and -1's, rather than a normalized set.
Then construct a file ex1 with these four values (separated by spaces or one value per line) and run the Haar transform as follows:
wavelet haar +1 < ex1(The +1 specifies the forward transform. To get the inverse transform, use -1.) Call the resulting vector Y. Your result will not agree with Y from the handout. The differences come from different normalization and phase (sign) conventions for the basis set. To see the actual basis set used by wavelet haar, do the inverse transform of the four basis vectors as follows:
echo "1 0 0 0" | wavelet haar -1 echo "0 1 0 0" | wavelet haar -1 echo "0 0 1 0" | wavelet haar -1 echo "0 0 0 1" | wavelet haar -1These basis vectors, call them e0, e1, e2, and e3, respectively, and the coefficients given by the forward transform should reproduce the signal. Check that
y = y0 e0 + y1 e1 + y2 e2 + y3 e3Compare this formula with the corresponding one in the handout and find the values y0, y1, y2, y3.
The executable ~p6730/exercises/fft/makeft does the inverse Fourier transform for real valued data. It takes a file of Fourier components and converts it to a real signal. The first line gives the number of real signal points N to be generated. The next line has three values: the frequency index followed by the real and imaginary values of the Fourier component for that frequency index. All Fourier components that are not listed are assumed to be zero. This simplifies the process of constructing the basis vectors. See the example file ex2. Notice that this file asks for 32 signal values and specifies a zero real part and unit imaginary part for Fourier component 4. All other components are zero. Look at the result from
makeft < ex2This result gives one of the Fourier "basis vectors".
Construct other basis vectors and plot them. The shortcut command
echo "32 4 0 1" | makeft | axis | xplotsimplifies the process. Our locally installed axis utility is described in the Computer Lab Manual in the axis chapter . It is far less sophisticated than gnuplot, but it takes plot data on standard input, so saves the trouble of creating an intermediate file for gnuplot.
What Fourier component gives a constant basis vector for all time values? What Fourier component gives a basis vector with constant magnitude but an alternating sign (+,-,+,-...) for the time values? What is the difference between a basis vector constructed with only a 1 in the real part and only a 1 in the imaginary part (for index values k > 0 and k < N/2)?
wavelet daub4 -1 < xfm | axis -a | xplot
(Here we have to use the -a automatic abscissa flag for
axis because wavelet generates only the "y" values.
To save you time, in the directory ~p6730/exercises/wavelets/ you will find several 32-component unit vectors. They are numbered from 1 to 32. Use them, the inverse transform and a plotting routine to explore the differences and similarities among the corresponding basis vectors. Construct more unit vectors if you need to. Classify the basis vectors according to how detailed they are. You should find six levels: (1) finest detail (2) next finest detail, etc., ending on (5) coarsest detail and (6) smooth. List the vector indices in each category. For example, you would say "(1) e32.17 through e32.32". These sets should contain 16, 8, 4, 2, 1, and 1 basis vectors, respectively.
wavelet daubn 4 -1 < xfm
wavelet daubn 12 -1 < xfm
wavelet daubn 20 -1 < xfm
Compare plots of the 256-component basis vectors constructed from the
file e256.4. Describe the differences.