Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

GNU Scientific Library - wavelet Transform

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
vipar
Posts: 4
Joined: 2016-09-27 16:27

GNU Scientific Library - wavelet Transform

#1 Post by vipar »

Hi,

I have implement gsl_wavelet_transform_forward function. I have no errors and program is running fine.
But i want to know how can i get frequency spectrum from the output data. I want to plot frequency vs Time to know what are the frequencies present in the input signal and how long they exsist. :roll:

Also, i have complared the output data obtained from the gsl function and manual data calculated from the wavelet transform algorithm(attached in the file) and found they are not different for same input data. Is there any other method by which gsl_wavelet_transform_forward function calculates the output.

Thanks in Advance

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: GNU Scientific Library - wavelet Transform

#2 Post by tomazzi »

Hi,
As far as I can understand Your post correctly, You just want to create a real-time spectrum analyzer?
Of course wavelets transformations are a bit different from fourier transformations, but in case of real-time analyzers the principle is the same: You just have to process the input signal using some time window of Your choice in a loop - and of course collect the data, so You can calculate the differences in the spectrum.

Or am I missing something?

Regards.
Odi profanum vulgus

vipar
Posts: 4
Joined: 2016-09-27 16:27

Re: GNU Scientific Library - wavelet Transform

#3 Post by vipar »

HI Tomazzi,

Thank you for the response. Okay let me put it in a more clear way.
In my program i have generated a mixed sine wave of 2 frequencies(say 1KHz and 5 KHz), then sampled the sine wave at equal intervals and gave it as input data to the GSL Wavelet Transform forward function and collected the output. Now finally when i plot the graph of time vs output data i want it to show me the band of frequencies in the input wave (ie a band of 1KHz and a band of 5KHz in this case). This can be obtained if i plot time vs Frequncy at each sample. But the output data collected is not the frequency. So i would like to know how to obtain the frequency also from the Transform. Is it possible? or do we have other methods for achieving this.

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: GNU Scientific Library - wavelet Transform

#4 Post by tomazzi »

Hi,
The first question here is what do You mean by "mixing" sinewaves?
Different method of mixing will produce different results (eg. multiplication vs subtraction)

The most important difference between fourier and wavelet transformations is that fourier returns only the component frequencies, while wavelet transform returns also some "artificial" bands which are calculated based on a sampling period instead of wave period.

So, I suppose that in Your case, the result contains a few other bands, not only 5 and 1KHz.

See also this: (especially the charts)
http://www.bearcave.com/misl/misl_tech/ ... index.html

Regards.
Odi profanum vulgus

vipar
Posts: 4
Joined: 2016-09-27 16:27

Re: GNU Scientific Library - wavelet Transform

#5 Post by vipar »

Mixing mean i have done addition of sine waves at different frequencies.

But my question was do we have a way to get the frequency values in the wavelet Transform

Thank You

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: GNU Scientific Library - wavelet Transform

#6 Post by tomazzi »

vipar wrote: (...)
But my question was do we have a way to get the frequency values in the wavelet Transform
No. We can get frequency ranges (bands).
Moreover, in the DWT the frequency is a function of time, but both time and frequency ranges are not defined as absolute values.

I'm not sure if You understand how the DWT works, but if You do, then here's the (simplified) explanation:
Assuming that we want to get absolute frequency values, and knowing that the DWT operates on frequencies from range 0..Fmax, where the Fmax is the Nyquist frequency of the sampler: (I'll use real values to show some real results)
Fsmp=24kHz - sampling frequency
Fnq=0.5*Fsmp=12kHz - Nyquist frequency, this is the Fmax for DWT.

Level 0 bands: (defined for coefficients [Cx], on this level)
C0=0..6kHz - Low band, both components of Your wave are here - non-zero, but nothing interesting to draw ;)
C1=6..12kHz - High band, coefficient should be zero in Your case.

Level 1 bands:
C0=0..3kHz - lowest band, contains one of your component frequencies (1kHz), non-zero.
C1=3..6kHz - contains second of your component frequencies (5kHz), non-zero.
C2=6..9kHz - should be zero.
C3=9..12kHz - as above.

etc, etc.

In other words, to calculate absolute frequency values, You need to know the sampling frequency or sample period.

The final accuracy (band width) is proportional to sampling frequency - or more precisely, to the number of samples within a given time window, as the maximum reachable level depends directly on the number of samples.

Regards.

PS:
If You need to easily extract particular component frequencies, then You can try to use FFT or maybe STFT fourier transformations.
Odi profanum vulgus

vipar
Posts: 4
Joined: 2016-09-27 16:27

Re: GNU Scientific Library - wavelet Transform

#7 Post by vipar »

Thank You. That was helpful.
Ya it can be done by STFT but wanted to try DWT instead of STFT because of the drawbacks.

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: GNU Scientific Library - wavelet Transform

#8 Post by tomazzi »

In fact, I've made a mistake - I'm really sorry for this, and as an excuse I can tell that I'm normally not using a plain DWT, but a DWPA (Discrete Wavelet Packet Analysis) - essentially, this is the same, but since the GSL uses "classic" DWT, the bandwidths are different:
Level 1: (using previous assumptions)
C0=0..3kHz
C1=3..6kHz
C2=6..12kHz
C3= <no C3 on this level>

"Classic" DWT works by de-composing only the lowest frequencies in the spectrum.

Regards.
Odi profanum vulgus

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: GNU Scientific Library - wavelet Transform

#9 Post by edbarx »

Intrnally, how do DWT and DWPA process input to get their output? What mathematical theorems do they use? I remember Fourier Analysis but that is used to analyse cyclic functions.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

tomazzi
Posts: 730
Joined: 2013-08-02 21:33

Re: GNU Scientific Library - wavelet Transform

#10 Post by tomazzi »

The mathematical theory is fully explained in related books, and this is really a huge amount of knowledge...
Shortened version is available on wiki

Good comparison and description of Fourier and Wavelet transforms:
http://web.iitd.ac.in/~sumeet/WaveletTutorial.pdf
edbarx wrote:Intrnally, how do DWT and DWPA process input to get their output?
Well, the best way to know how it works is to just check the GSL sources:
http://git.savannah.gnu.org/cgit/gsl.git/tree/wavelet

The implementation is surprisingly simple, thanks to use of pre-calculated coefficients for particular wavelet transformations (eg. Daubechies)
The key function is dwt_step() in dwt.c

Regards.
Odi profanum vulgus

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: GNU Scientific Library - wavelet Transform

#11 Post by edbarx »

tomazzi wrote:The mathematical theory is fully explained in related books, and this is really a huge amount of knowledge...
This looks like an application of integration and differentiation. It looks like the right 'puzzle' for some afternoon. I still remember the derivation for Fourier Analysis which I studied around 30 years ago.

Thanks.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

Post Reply