Purdue Digital Signal Processing Labs by Charles A. Bouman - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Chapter 12Lab 7c - Power Spectrum Estimation

Questions or comments concerning this laboratory should be directed to Prof. Charles A. Bouman, School of Electrical and Computer Engineering, Purdue University, West Lafayette IN 47907; (765) 494-0340; bouman@ecn.purdue.edu

Introduction

In the first and second weeks of this experiment, we introduced methods of statistically characterizing random processes. The sample autocorrelation and cross correlation are examples of “time domain” characterizations of random signals. In many applications, it can also be useful to get the frequency domain characteristics of a random process. Examples include detection of sinusoidal signals in noise, speech recognition and coding, and range estimation in radar systems.

In this week, we will introduce methods to estimate the power spectrum of a random signal given a finite number of observations. We will examine the effectiveness of the periodogram for spectrum estimation, and introduce the spectrogram to characterize a nonstationary random processes.

Power Spectrum Estimation

In this section, you will estimate the power spectrum of a stationary discrete random process. The power spectrum is defined as

(12.1)
_autogen-svg2png-0001.png

There are 4 steps for calculating a power spectrum:

  1. Select a window of length N and generate a finite sequence x(0),x(1),⋯,x(N–1).

  2. Calculate the DTFT of the windowed sequence x(n), (n=0,1,⋯,N–1), square the magnitude of the DTFT and divide it by the length of the sequence.

  3. Take the expectation with respect to x.

  4. Let the length of the window go to infinity.

In real applications, we can only approximate the power spectrum. Two methods are introduced in this section. They are the periodogram and the averaged periodogram.

Periodogram

Click here for help on the fft command and the random command.

The periodogram is a simple and common method for estimating a power spectrum. Given a finite duration discrete random sequence x(n), (n=0,1,⋯,N–1), the periodogram is defined as

(12.2)
_autogen-svg2png-0009.png

where X(ω) is the Discrete Time Fourier Transform (DTFT) of x(n).

The periodogram Pxx(ω) can be computed using the Discrete Fourier Transformation (DFT), which in turn can be efficiently computed by the Fast Fourier Transformation (FFT). If x(n) is of length N, you can compute an N-point DFT.

(12.3)
_autogen-svg2png-0016.png
(12.4)
_autogen-svg2png-0017.png

Using Equation 12.3 and Equation 12.4, write a Matlab function called Pgram to calculate the periodogram. The syntax for this function should be

[P,w] = Pgram(x)

where x is a discrete random sequence of length N. The outputs of this command are P, the samples of the periodogram, and w, the corresponding frequencies of the samples. Both P and w should be vectors of length N.

Now, let x be a Gaussian (Normal) random variable with mean 0 and variance 1. Use Matlab function random or randn to generate 1024 i.i.d. samples of x, and denote them as x0, x1, ..., x1023. Then filter the samples of x with the filter which obeys the following difference equation

(12.5)
_autogen-svg2png-0031.png

Denote the output of the filter as y0,y1,⋯,y1023.

The samples of x(n) and y(n) will be used in the following sections. Please save them.

Use your Pgram function to estimate the power spectrum of y(n), _autogen-svg2png-0036.png. Plot _autogen-svg2png-0037.png vs. ωk.

Next, estimate the power spectrum of y, _autogen-svg2png-0040.png using 1/4 of the samples of y. Do this only using samples y0, y1, , y255. Plot _autogen-svg2png-0047.png vs. ωk.

INLAB REPORT

  1. Hand in your labeled plots and your Pgram code.

  2. Compare the two plots. The first plot uses 4 times as many samples as the second one. Is the first one a better estimation than the second one? Does the first give you a smoother estimation?

  3. Judging from the results, when the number of samples of a discrete random variable becomes larger, will the estimated power spectrum be smoother?

Averaged Periodogram

The periodogram is a simple method, but it does not yield very good results. To get a better estimate of the power spectrum, we will introduce Bartlett's method, also known as the averaged periodogram. This method has three steps. Suppose we have a length-N sequence x(n).

  1. Subdivide x(n) into K nonoverlapping segments of length M. Denote the ith segment as xi(n).

    (12.6)
    _autogen-svg2png-0055.png
  2. For each segment xi(n), compute its periodogram

    (12.7)
    _autogen-svg2png-0057.png
    (12.8)
    _autogen-svg2png-0058.png

    where k=0,1,⋯,M–1 and i=0,1,⋯,K–1.

  3. Average the periodograms over all K segments to obtain the averaged periodogram, PAxx(k),

    (12.9)
    _autogen-svg2png-0063.png
    (12.10)
    _autogen-svg2png-0064.png

    where k=0,1,⋯,M–1.

Write a Matlab function called AvPgram to calculate the averaged periodogram, using the above steps. The syntax for this function should be

[P,w] = AvPgram(x, K)

where x is a discrete random sequence of length N and the K is the number of nonoverlapping segments. The outputs of this command are P, the samples of the averaged periodogram, and w, the corresponding frequencies of the samples. Both P and w should be vectors of length M where N=KM. You may use your Pgram function.

Hint

The command A=reshape(x,M,K) will orient length M segments of the vector x into K columns of the matrix A.

Use your Matlab function AvPgram to estimate the power spectrum of y(n) which was generated in the previous section. Use all 1024 samples of y(n), and let K=16. Plot P vs. w.

INLAB REPORT

  1. Submit your plot and your AvPgram code.

  2. Compare the power spectrum that you estimated using the averaged periodogram with the one you calculated in the previous section using the standard periodogram. What differences do you observe? Which do you prefer?

Power Spectrum and LTI Systems

Figure (sys.png)
Figure 12.1
An LTI system

Consider a linear time-invariant system with frequency response _autogen-svg2png-0082.png, where Sxx(ω) is the power spectrum of the input signal, and Syy(ω) is the power spectrum of the output signal. It can be shown that these quantities are related by

(12.11)
_autogen-svg2png-0085.png

In the "Periodogram" section, the sequence y(n) was generated by filtering an i.i.d. Gaussian (mean=0, variance=1) sequence x(n), using the filter in Equation 12.5. By hand, calculate the power spectrum Sxx(ω) of x(n), the frequency response of the filter, _autogen-svg2png-0090.png, and the power spectrum Syy(ω) of y(n).

Hint

In computing Sxx(ω), use the fact that _autogen-svg2png-0094.png

Plot Syy(ω) vs. ω, and compare it with the plots from the "Periodogram" and "Averaged Periodogram" sections. What do you observe?

INLAB REPORT

  1. Hand in your plot.

  2. Submit your analytical calculations for Sxx(ω), _autogen-svg2png-0098.png, Syy(ω).

  3. Compare the theoretical power spectrum of Syy(ω) with the power spectrum estimated using the standard periodogram. What can you conclude?

  4. Compare the theoretical power spectrum of Syy(ω) with the power spectrum estimated using the averaged periodogram. What can you conclude?

Estimate the Power Spectrum of a Speech Signal

Download the file speech.au for this section. For help on the following Matlab topics select the corresponding link: how to load and play audio signals and specgram function.

The methods used in the last two sections can only be applied to stationary random processes. However, most signals in nature are not stationary. For a nonstationary random process, one way to analyze it is to subdivide the signal into segments (which may be overlapping) and treat each segment as a stationary process. Then we can calculate the power spectrum of each segment. This yields what we call a spectrogram.

While it is debatable whether or not a speech signal is actually random, in many applications it is necessary to model it as being so. In this section, you are going to use the Matlab command specgram to calculate the spectrogram of a speech signal. Read the help for the specgram function. Find out what the command does, and how to calculate and draw a spectrogram.

Draw the spectrogram of the speech signal in speech.au. When using the specgram command with no output arguments, the absolute value of the spectrogram will be plotted. Therefore you can use

speech=auread('speech.au');

to read the speech signal and use

specgram(speech);

to draw the spectrogram.

INLAB REPORT

  1. Hand in your spectrogram plot.

  2. Describe the information that the spectrogram is giving you.

Solutions