# Wavelets in signal analysis

Let's suppose that we are not satisfied with sines because the resolution of the periodogram on the time axis is not good enough. One option is to use wavelets. Here are some of their properties:

- A wavelet is a function whose two versions of different "frequency" are orthogonal to each other. (Like two sines of different frequencies). Wavelets therefore fit the frequency in much the same way as the DFT. The problem of using the word frequency lies in the fact that this word is strongly associated with sines. Therefore the word scale was used when it came to wavelets and was defined as: Scale = 1/freq.
- Wavelets of lower frequencies are longer then wavelets of higher frequencies. For all frequencies the DFT will use the same full length of the time series to which the sines will be fitted. Wavelets reduce that length, towards higher frequencies. You can’t fit a sine (or any other function) unless you have at least one full period (for sine of 1Hz at least 1s) available, or ambiguity would occur. With higher frequencies the periods get shorter. DFT offers only one value of how much energy is present at a single frequency across the whole time series, and the wavelets are moving along the series to cover the whole range and return one value for each position in the time series. This is called "shifting". That is why wavelets give better resolution in time; more values for high frequencies where DFT gives only one.
- The DFT used a neat trick (combination of sine and cosine) to get actual amplitude and phase. The wavelets do not make use of that and they have to move along the whole time series (shifting) to check for each possible value of the phase of the frequency currently fitting. We could do the same thing with sine’s (DFT), but the computational complexity would explode. And with wavelets that simply does happen. This approach is called continuous wavelet analysis.
- Discrete wavelet analysis solves the problem of exploding computation complexity. The idea is to down sample the signal after high frequencies have been extracted. We need high sample rates to catch high frequencies without causing ambiguity (aliasing) with the low frequencies. Because we analyze high frequencies first and then the lower, we can filter out the frequency band that we no longer need and lower the sampling frequency to reduce the computational requirement for the next stage. But to reduce the sampling frequency, an anti-aliasing filter is needed. This filtering is performed by wavelet analysis itself. And this directly means less calculation. The anti-aliasing filtering poses another set of constraints upon the wavelet shape.

The application of wavelets:

- Because wavelets are shorter for high frequencies than sines in DFT, they give more localized information about the amplitude. Wavelets do not return the amplitude and the phase, but only the actual amplitude at the specific position within time series. The information of the frequency we already have, since we know what the frequency of the wavelet currently being shifted is and the amplitude has to be read out.

When we begin fitting the wavelets to time series, we can select the number of different frequencies that will be fitted and what those frequencies will be. For practical reasons the frequencies selected are always power of two. For example, if we have a signal of 256 samples within a time span of 1s, the highest frequency in the signal is 128 Hz. This is the first fitting frequency, the next are 64, 32, 16, 8, 4 and 2. We have to downsample the signal after each fitting to save CPU time. After the fit of 128 Hz we apply anti-aliasing filter and sample down by a factor of two. We now have only 128 samples on which the 64 Hz wavelet will be applied and so on. We define the number of frequencies (that are power of two) that will be fitted with the parameter called: Decomposition Level. - Selection of the wavelet. This is the most interesting question for most of the users. The wavelet has one or two parameters. Because wavelets have so many constraints, that are not associated with signal, but more with math and calculation limitations, it is virtually impossible to blindly select a wavelet. There are 6 types of wavelets included with FFT Properties. Luckily the number of all existing wavelets is rather small and it is not hard to try them out. The most general purpose usable wavelet is called the Daublet wavelet. The Haar wavelet is actually a differential operator. The daublet 1 equals Haar. As mentioned, the wavelets have one primary parameter. This parameter defines two things: region of support and the number of vanishing moments. The region of support means, how long the wavelet is. This will affect the localization capabilities. The longer the wavelet, the larger part of the time series will be taken in to account when calculating the amplitude at the specific time position and more averaging will occur, similar to that in DFT.
- The number of vanishing moments is always the same as the region of support level. The number of vanishing moments defines the polynomial order of the polynomial that will be ignored if present in the time series. If we add x1[i]^3+x2[i]^2 (sample by sample) to our original signal and define the number of vanishing moments to be 3, than the whole addedseries will not be modified when performing the wavelet decomposition. If the number of vanishing moments would be 2, than only the parabola part of the series added to the original signal would be ignored.
- Approximations and detail. If we fit a wavelet at level 1 to the original signal, then the result of the fitting is called Detail and has two times less samples than the original (because the length in samples of the wavelet at level 1 is 2). The signal that has been downsampled after that fitting to be prepared for the next level wavelet fitting is called Approximation. The sum of details equals the original signal. (If downsampling is reversed for each approximation and detail.) This is called: wavelet reconstruction.
- Packet analysis. If not only approximations but also details are being further decomposed, we talk about wavelet packet analysis. This results in a balanced binary tree structure. The bottom leaves contain detailed information for each frequency. In compare to simple wavelet analysis the packet analysis offers much better frequency resolution. DFT based periodogram would have 128 frequency lines from a signal with 256 samples and simple wavelet analysis would give only 8 lines (Level 1: 128Hz, Level 2: 64Hz,Level 3: 32Hz, Level 4: 16Hz,Level 5: 8Hz, Level 6: 4Hz,Level 7: 2Hz,Level 8: 1Hz). Wavelet packet analysis can produce all the frequencies as the DFT. To perform partial packet analysis, you can save one of the wavelet details to a file and then perform wavelet decomposition on that detail.