# Wavelets and Time-Frequency Analysis

## Abstract

This article presents a comparison between the time-frequency analysis and the Wavelet analysis. The Short-time Fourier transform is used for the purpose of time-frequency analysis. We have presented examples to describe the concepts. More emphasis is given to the time-frequency analysis as the Wavelet analysis is closely related to it. In the section of time-frequency analysis we develop some concepts and extend these to the Wavelet analysis.

## Description

The Fourier transform of a signal x(t) is defined as follows.

Here X(f) is the Fourier transform of x(t). The Fourier transform is one-to-one, hence X(f) and x(t) determines completely the properties of each representation. However it is not always possible to determine the properties of a signal completely with the help of Fourier transform. This is because of a drawback in Fourier transform. The time information is lost when Fourier transform of a signal is taken. In this way we are unable to tell when in time a particular event took place.

This is not a problem for signals which are stationary. In stationary signals all frequency components are evenly divided all over the time. Hence in such signals it is not necessary to
determine when in time a particular frequency occurred. In fact it is useless to do so for stationary signals. But when we have a signal which changes with time, we need more information about the signal behaviour. This can not be determined completely with Fourier Analysis. So we have to move to another solution for time-varying or non-stationary signals.

## Examples and Discussion

Let us describe the above concepts with the help of some examples.

### Stationary Signal

Consider a signal x(t) shown in figure 1. This is a stationary signal as all frequency components are present at all times. Its mathematical representation is given below. When we take the Fourier transform of this signal we have the frequency plots as shown in figure 2. It can be seen from frequency resolution that 50, 120 and 150 Hz components are present in the signal.

Stationary Signal x(t)
Fourier Transform of x(t)

### Non-Stationary Signal

Now we have to show what happens when we use a non-stationary signal. To describe the difference we use a non-stationary signal with the same frequency contents as the above stationary signal. Let the signal be mathematically written as follows. The equation shows that there are three frequency components each of which occur independently after a particular time-period.

The non-stationary signal

Now one can imagine what will happen when we take the Fourier transform of this signal. It will be exactly same as the Fourier transform of the previous signal. This means that we are getting the same Fourier transform for two completely different signals. At this point we would like to state that Fourier transform is unable to deal comprehensively with non-stationary signals as the temporal behaviour of the signal is lost.

When we are talking about Fourier transform we are in fact talking about the two different representations of same signal. Each represent different features of the signal. If we combine the features of each of the representation we will get what is called time-frequency representation. In time-frequency analysis the features of X(f) and x(t) are combined into a single function, and we call it time-frequency representation.

## Time-Frequency Analysis

The goal of time-frequency analysis is to find what frequency occurs at what time in a signal. This means that we have to find a representation X(t,f) for that signal which can relate the time and frequency information.

There are different types of transforms available for time-frequency analysis. The most commonly used of these is the Short-Time Fourier Transform (STFT). This transform as its name says use Fourier transform as a tool to find time-frequency representation of a signal. The time-frequency resolution obtained using STFT can be shown using a spectrogram. A spectrogram gives a view of the energy division in a signal with respect to time and frequency. There are other methods to display the time-fequency resolution of a signal. We will try to use several of these to show the concept of time-frequency analysis.

## Short-Time Fourier Transform

Lets see what is actually the Short-Time-Fourier Transform (STFT). The name says that we are going to use the Fourier transform. The STFT uses the Fourier transform for short periods of time. Let us elaborate about this. As we know the Fourier transform works well for the stationary signals, we are going to divide our non-stationary signal such that each division is stationary. Here it must be understood that it is assumed the signal is not changed for that particular period.

The division of the signal can be done with the help of windowing technique. In order to do this we multiply the signal x(t) in time domain by a succession of windows.

Blackman Window

These windows can be of different types, Gaussian, Blackman, Hanning, Hamming, etc. The Blackman window shown in figure 4 was used for this purpose. We can show the window function mathematically as

Each window w(t-\tau_m) is centered at time \tau_m. We multiply the window function with the signal x(t). This function is such that the following equation holds.

So now we can see from here that the original signal x(t) is equal to the sum of sub-signals f(t)w(t-\tau_m). In this way we have several subsignals to apply Fourier transform on. So we get the frequency information that is localized in time and we are able to tell what frequency occurs at what time. The general equation for STFT can be written as follows.

## Examples and Discussion

Let us elaborate the above concepts with the help of some examples. Plots are also shown for clarification.

### Non-stationary signal 1

We again consider the non-stationary signal x(t) from the previous section.
We use MATLAB to get the subsignals with the help of windowing operation. (Note: If you are new to MATLAB, I would suggest the book 'Mastering MATLAB' as one of the best reference). Once we get the subsignals we perform Fourier transform of each of those to get the localized information.

The Short-Time Fourier Transform results for this signal are shown below.

Each of the above subplots show the frequency content of x(t) for different time periods starting from the top subplot. The window length used for this plot is 100. It can be easily seen
that for the initial three time-periods, only one frequency (50 Hz) was present. After that the second frequency (120 Hz) occurred and then the 150 Hz frequency occurred separately in time. So by looking at the STFT result one can easily determine what frequency is present at what time.

It can be added that if more than one frequency is present at a particular time-period then it will also be visible in the plots. For this purpose we will see STFT results for another signal.

### Non-stationary signal 2 (The Chirp signal)

Lets consider the example of chirp signal from MATLAB. This is a non-stationary signal shown below.

Chirp signal from MATLAB

The Fourier transform of this chirp signal follows in figure 8. Note that the figure has been zoomed in to show the details about frequency content. We observe that 310, 325, 340, 420 Hz frequency components are present.

Fourier transform of Chirp signal

Lets look at the time-frequency representation of this signal. It is shown in figure 9. We can see that more details are available in this representation. This is because STFT was able to detect changes in frequency due to windowing. Now we can say that the frequencies present in this signal are 270, 290, 300-340, 410, 420 Hz.

The chirp signal time-frequency representation using STFT

So for signals with sharp changes the STFT is performing better than the common Fourier analysis. One thing we must note here is the power of signal at particular frequency components. If we note carefully in the STFT plot we will see that the signal is most powerful when 300-310 Hz frequency occurs and this can be verified from the simple Fourier transform of the signal also.

## Spectrogram

In this section we will discuss an important method for visualizing the time-frequency representation of signals. In spectrogram we have a time-frequency plane. This plane determines the power of signal at different frequencies occurring in time. Please note that the STFT is used for the spectrogram in MATLAB. For example consider the stationary signal x(t)

Spectrogram of the stationary signal

This is the spectrogram of the signal given above. In this spectrogram we can see three bright bands. These bright bands show the frequencies present in the signal. It can be easily seen that these three frequencies are occurring at all times. On the other hand these bands will be discontinuous for a non-stationary signal. Different bands will occur at different times and for varying duration.

The spectrogram of the non-stationary signal

is shown below. In this spectrogram three different bands occur at different times showing the non-stationary behaviour of the signal. We also note the vertical bands, showing the presence of all frequencies for a particular time-period. This is because of the discontinuity in the signal at that instant.

Spectrogram of the non-stationary signal

## Some changes

In all of the previous examples we have seen that we are looking for the frequency resolution for a particular time-period. Moreover we also observe that the frequency resolution is not
fine. We are getting a band of frequency instead of a single frequency. If we want to know the frequency information at any instant what should we do? We just have to shorten the size of our window function. In all previous examples I have used Blackman window for this purpose with size 100. Lets decrease the size of the window to 50 and see what happens. We will use the STFT for this purpose and show the results using spectrogram.

Spectrogram of the non-stationary signal with short window size (50)
Spectrogram of the non-stationary signal with short window size (10)

The results are shown in figure 12 and 13. As it can be seen the frequency resolution is now worst than the previous. This will continue to happen as the window size is decreased.

All frequency information is lost in the last transform of figure 13 and it is impossible to determine what frequencies are present in the signal from this spectrogram. So we can say that if we want good time-resolution, the frequency information is lost. Similarly it can be observed that if we increase the frequency resolution, the time information is lost. So we can not at the same time have both time and frequency resolution such that it could be determined what frequency is present at a particular time instant. This limitation is according to the Heisenberg uncertainty principle described below.

## Heisenberg Uncertainty Principle

The resolution in time and frequency can not be arbitrarily small, because their product is lower bounded.

This is referred to as the uncertainty principle or Heisenberg inequality. It means that one can only trade time resolution for frequency resolution, or vice versa.

## Problem with the Time-Frequency Representation

The Time-Frequency representation enables us to analyze the non-stationary signals. For non-stationary signals the separate time and frequency representation can not work. The STFT (one of the Time-Frequency analysis tools) can be used to determine the time-frequency image of a signal. The efficiency of time-frequency analysis is limited by the Heisenberg uncertainty principle. For narrow windows we get good time-resolution but poor frequency resolution. For wide windows we get good frequency resolution and poor time-resolution.

## Solution for the problem

The problem with Time-Frequency analysis is due to the constant length windows. In STFT we used constant length windows. These fixed length windows give the uniform partition of the time-frequency plane. Due to these we are limiting ourselves with a single resolution for complete signal. Most of the signals of practical interest are such that they have high frequency components for short durations and low frequency components for long durations. So the solution for this problem could be to use Multi resolution analysis such that it gives good time resolution and poor frequency resolution at high frequencies and good frequency resolution but poor time resolution for low frequencies. This kind of analysis tool is called the Wavelet transform discussed in the next section.

## Wavelet Transform

The Wavelet transform is a tool that cuts up data or functions or operators into different frequency components, and then studies each component with a resolution matched to its scale.

Whereas the parameters in time-frequency analysis are time t and frequency f, the parameters in wavelet theory are time t and scales s. The continuous Wavelet transform is defined by the following equation.

here, \tau and s are time and scale parameters as mentioned above. In time-frequency analysis we multiplied the original signal with windows of same sizes at different time intervals. The Wavelet analysis is similar to the time-frequency analysis in the sense that we multiply the original signal x(t) with the wavelets of different sizes and at different time intervals. This wavelet function is defined by

here \tau determines the translation in time for the wavelet, while s determines the scale of the wavelet. By scale in general terms we mean the size of the wavelet. To understand more about the scale we shall look at the wavelet.

## Wavelet

A wavelet is a waveform of limited duration that has an average value of zero. Fourier Analysis breaks up a signal to be analyzed into sine waves of different frequencies. Wavelet Analysis in the similar manner is to break up the signal into shifted and scaled versions of Wavelets.

## Description

### Scale

We have talked about the scale of wavelets as the size of wavelets. The scale corresponds to the shape of the wavelet. In wavelet analysis we use compressed and stretched versions of mother wavelet. When we talk about mother wavelet we mean the wavelet which is in its original shape. The compression and stretch of this mother wavelet is controlled by the scale factor. If the scale is small (or less than 1) we can say that the wavelet we will get is compressed. The wavelet corresponding to the scale value equal to the 1 is original or mother wavelet. If stretched versions of mother wavelet are required we simply increase the scale. The large values of scale(s) correspond to small values of frequency(f). This means that if the scale value is large we are looking at lower frequencies in the signal. At large values of s the frequency resolution is poor but time resolution is improved. At lower values of scale the frequency resolution is increased. This is according to our requirements, as most of the natural signals have high frequency components for very short periods and low frequency content is spread allover the time. The division of the time-frequency plane and the time-scale plane is shown below in figure 17 and 18.

Time-Frequency Plane
Time-Scale Plane

In STFT we moved a window of constant size over signal to find the frequency content localized in time. In Wavelet analysis we move the different scaled versions of the mother wavelet and calculate the correlation between the signal and that wavelet. In this way we get wavelet coefficients. These coefficients can be used to draw what is called scalogram. A scalogram is described by a time-scale plane. We will be looking at scalogram in the following
section for different cases of signals.

## Examples and Discussion

We shall consider the examples of stationary and non-stationary signals similar to those we discussed for the Fourier analysis and STFT with some changes. For all of the following examples I will be using different types of wavelets from the MATLAB.

### Stationary Signal

First consider the stationary signal

Another stationary signal

Its Wavelet analysis (time-scale plot) is shown below. The first plot is when the db2' wavelet was used. The next plot is for the db24' wavelet.

Wavelet analysis of stationary signal with db2'.
Wavelet analysis of stationary signal with db24'.

### Non-stationary Signal 1

Now we shall consider the non-stationary signal given below

The signal and its Wavelet analysis (time-scale plot) is shown below using both db2' and db24' wavelets. For a nonstationary signal, different frequencies are present at different times. So unlike the scalogram for previous signals the scalogram for this type of signals will not be symmetric. In fact we will see different bands in the scalogram. Each band shows the presence of that particular frequency for that particular time.

Another nonstationary signal
Wavelet analysis of non-stationary signal with db2'.
Wavelet analysis of non-stationary signal with db24'.
Wavelet analysis of non-stationary signal (Chirp) db2'.

### Non-stationary signal 2 (Chirp)

Now consider the chirp signal shown in figure 7. We know that the Fourier analysis of this signal determined that it consists of high-frequency components. So in the wavelet analysis of this signal we find that there is no need to plot the wavelet components for high scale values. The plot shown below also determines that the time-resolution is high and the frequency resolution is poor. But the good thing is we can easily determine that at any particular time what frequencies were present and we can also determine the power of all those frequencies. The most bright parts of this plot shows that the frequency component is of higher power than with less bright parts.

## Conclusion

The different signal analysis techniques were discussed in this report. We tried to use same type of signals for all of the three techniques used. It was found that for stationary signals the simple Fourier analysis provides complete information. If the signal is non-stationary the Fourier analysis fails and we have to go for time-frequency analysis. Short-Time Fourier transform provides time-frequency representation of a signal. The resolution of time and frequency can be controlled by the size of the window used. The drawback with the time-frequency (STFT) analysis was that we can not get high resolution in both time and frequency. For a higher resolution in one domain we have to sacrifice resolution in other. The reason for this was same size window. The problem was solved by finding a representation using wavelets. This technique is similar to the time-frequency analysis in that instead of windows, wavelets are used. The important thing is that we use scaled and shifted versions of the wavelet. The result obtained using this is more helpful in determining the characteristics of natural signals. The results that we have shown here were generated using similar signals. It can be said that our findings are restricted to these signals only. It may vary if different conditions are used.

## References

• Ingrid Daubechies , Ten Lectures on Wavelets'', CBMS, SIAM, 1994.
• Karlheinz Grochenig, Foundations of Time-Frequency Analysis'', Birkhauser, 2001.
• Olivier Rioul, Martin Vitterli, Wavelets and Signal Processing'', IEEE Signal Processing Magazine., 1991.
• Robi Polikar, The Wavelet Tutorial''
• Nikolaj Hess-Nielsen, Mladen Victor Wickerhauser, Wavelets and Time-Frequency Analysis'', IEEE Proceedings, 84(4):523, 1996.
• F. Hlawatsch, G.F.Boudreaux-Bartels, `Linear and Quadratic Time-Frequency Signal Representations'', IEEE Signal Processing Magazine, 1992.

## More by this Author

Kavan 6 years ago

Can anyone comment on the statement "The time information is lost when Fourier transform of a signal is taken. In this way we are unable to tell when in time a particular event took place."

Why? I get that all spectral components act globaly ,during the whole duration of the signal, but why can't we tell when a particular event took place?

thanks

kavan

Phil 6 years ago

I believe that this is due to the fact that the Fourier transform is from -inf to +inf. Since the integral is over all time, the location of a specific frequency in time is lost. The STFT helps since you're splitting the integration into specific windows in time. Wavelets take the STFT windowing to another level.

Hope that helps.

- Phil

Pawel Rzeszucinski 6 years ago

Phil is right. The reason for that lies in the fact, that conventional FFT calculates the energy distribution in the whole length of the signal at once.

Imagine recording an Alicia Keys concert. After the show you calculate FFT of the recording - you can easily detect and distinguish frequencies coming from drums (low frequency) and, say, piano assuming she played relatively high frequencies. However, since FFT takes the whole signal as one periodic wave, you are not able to say WHEN exactly the drum was engaged, and WHEN piano took over.

On the other hand if you took only short intervals of the whole recordings and performed FFT it would be much easier to localise given instrument in time (provided you know the order of windowing). This is how you end up with STFT. In a big simplification.

Tahir Ahmed 5 years ago

Hi Mudasir,

Its very well explained. Thanks for posting. It helped me.

Gud luck for future.

Regards,

Tahir