Orthogonality of wavelets / scaling function

124 views
Skip to first unread message

Wilfred van Rooijen

unread,
Sep 9, 2011, 9:47:42 AM9/9/11
to PyWavelets
Hello, this may be a FAQ but I am lost and Google didn't help very
much. This is my problem. I am quite new to wavelets. I have taken the
pyWavelets package to study wavelets. I have reprogrammed a large
portion in F95 for future use in a code I am developing.

I am working on some analysis, where I decompose a signal (always
positive values) with a multi-level DWT. This gives me several arrays
of "average coefficients" and "detail coefficients". In my further
analysis, I need to have the actual wavelets for each level and
offset, and then integrate the product of two wavelets and the signal.
I use the orthogonal wavelets, so if I integrate only two wavelets, I
expect that the integral is zero if the wavelets are different, and
non-zero if the wavelets are the same. So, I take the arrays of
coefficients, set all coefficients to zero, then set the coefficient
to 1.0 for the relevant level and offset, and I use the inverse multi-
level DWT. And much to my surprise, I find that the wavelets appear to
be non-orthogonal! What am I doing wrong? Please see the attached
code:

#! /usr/bin/env python

import pywt
import pylab as pl

w = pywt.Wavelet( 'sym6' )
mode = 'per'

coefs = []
coefs.append( pl.zeros( 18 ))
coefs.append( pl.zeros( 18 ))
coefs.append( pl.zeros( 36 ))
coefs.append( pl.zeros( 71 ))
coefs.append( pl.zeros( 141 ))
coefs.append( pl.zeros( 282 ))
coefs.append( pl.zeros( 563 ))
coefs.append( pl.zeros( 1125 ))
coefs.append( pl.zeros( 2250 ))
coefs.append( pl.zeros( 4500 ))
coefs.append( pl.zeros( 9000 ))
coefs[0][0] = 1.0

print w
print ""
print " DWT Filter dec_lo : ", w.dec_lo
print " "
print " DWT Filter dec_hi : ", w.dec_hi
print " "
print " IDWT Filter rec_lo : ", w.rec_lo
print " "
print " IDWT Filter rec_hi : ", w.rec_hi
print " "
print " Sum of of coefficients : " , pl.sum( w.dec_lo )

tot = 0.0
for i in range( w.dec_len ):
tot = tot + w.dec_lo[i] * w.dec_lo[i]
print " Coeff. sum of squares : ", tot

output1 = pywt.waverec( coefs, w, mode )
print " Approx. integral : ", pl.sum( output1 )

coefs[0][0] = 0.0
coefs[0][0] = 1.0
output2 = pywt.waverec( coefs, w, mode )
output = output1*output2
pl.plot( output )
print " Approx. int. of prod. : ", pl.sum( output )
pl.show()

Much to my surprise, if I set coefs[0][1] = 1.0 for the second
wavelet, then the result for the integral is not zero, in fact it is
quite far from zero. Also, I seem to remember that the wavelet
coefficients are usually scaled so that the wavelets are orthonormal.
How can I do this?

Thanks,
Wilfred
Reply all
Reply to author
Forward
0 new messages