I've recently started working with wavelets, and want to focus primarily on Discrete Wavelet Transform. For experimental purposes, I use the PyWavelets library in Python. In one of my tests, I tried the following code.

Basically, I randomly sample the coefficients for the lowpass and highpass filters from a normal distribution, and use those coefficients to plot the scaling and wavelet functions.

import matplotlib.pyplot as plt
import pywt
import numpy as np

fig = plt.figure()
fig.subplots_adjust(hspace=0.2, wspace=0.2, bottom=.02, left=.06,
                        right=.97, top=.94)

dec_lo, dec_hi, rec_lo, rec_hi = np.random.normal(0.0, 0.5, (4, 2)).tolist()
print(dec_lo, ' ', dec_hi, ' ', rec_lo, ' ', rec_hi)
filter_bank = [dec_lo, dec_hi, rec_lo, rec_hi]
wavelet = pywt.Wavelet(name="myWavelet", filter_bank=filter_bank)

phi, psi, _, _, x = wavelet.wavefun(level=5)

color = 'red'
ax = fig.add_subplot(1, 2, 1)
ax.set_title(wavelet.name + " phi")
ax.plot(x, phi, color)
ax.set_xlim(min(x), max(x))

ax = fig.add_subplot(1, 2, 2)
ax.set_title(wavelet.name + " psi")
ax.plot(x, psi, color)
ax.set_xlim(min(x), max(x))


A run of the above code gave me the following plot (Since values are randomly sampled, different runs will give different plots): enter image description here

My question is, can it be shown that these plots are valid scaling and wavelet functions? Or are they simply meaningless plots generated for the sampled coefficients?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.