Docsity

Assignment 1 Solutions - Digital Signal Processing | EE 275, Assignments of Digital Signal Processing

Toggle sidebar
bg1
EE275 (September 14, 2008)
Digital Signal Processing & Filtering Fall Semester 2008
H O M E W O R K NO. 1 SOLUTION & COMMENTS
[2.1] X= rand(N,1) generates N samples of a random variable X that are uniformly distributed on [0,1].
(Alternatively, you can look upon the sequence generated as a realization of a random process with in-
dividual samples as random variables). Using hist(X) gives you a histogram, which is a non-normalised
approximation to the pdf, which shows you how good a uniform pdf you have. In problem 2.1, the
signal is the same for a number of additions of noise vectors. The averaging then effectively operates
on the ensemble of noise, that is, the 50 realizations, thereby smoothing the noise. The signal, which
is ā€œfixedā€ is not affected. Note that you can also time averaging as in problem 2.4.
Other observations: For the noise vector x, autocorrelation Rx(m) (the time-averaging one) is defined
as
Rx(m) = X
n
x(n)x(m+n)
The MATLAB function y=xcorr(x, x) accomplishes that. Better yet, use the covariance function
y=xcov(x) which is defined as
Cx(m) = X
n
(x(n)āˆ’ĀÆx)(x(n+m)āˆ’ĀÆx)
where ĀÆxis the mean value of x. Here you see more of a ā€œdelta-functionā€ that implies decorelation of
neighboring samples.
So, using y=xcov(x), plot(y) gives a plot of the covariance of xand shows you how well the noise is
decorrelated. Note that the white part of white noise refers to the fact that since all samples are ideally
uncorrelated i.e. Rx(m) = Pmx(n)x(n+m) = Ī“(m). The Power Spectral density Sx(ejω ), which is
the DFT of Rx(m), will be 1 for all frequencies Ļ‰āˆˆĻ€. Hence the term white noise.
Note also that the pdf of white noise may be Uniform, Gaussian, Poisson or any other distribution.
The whiteness and distribution are independent.
Once you have white noise i.e. a flat spectrum, you can apply that noise to a filter, say a low pass
filter. The output power spectral density Sy(ω) will no longer be flat. You now have colored noise.
[2.2] Generating a complex exponential sequence; plotting the real and imaginary parts. Using .01 for the
real exponent, .1Ļ€for the imaginary exponent, amplitude of 1 and signal length of 100 we get signals
as in Figures 1(a) and 1(b). That is, exponentially decreasing sinusoids.
[2.3] Generating a real exponential sequence, using real arguments.
[2.4] A MA filter is an averaging filter where the averaged portion of the input moves. That is, for example
y[n] = 1
3(x[n] + x[nāˆ’1] + x[nāˆ’2]) gives a 3-point MA filter. You have a M-point MA filter. This type
of averaging is ā€œtime-averagingā€ (of a single time series) as opposed to averaging over an ensemble as
in problem 2.1.
We observe that for small M(3) the filtered signal still shows noise. For large M (20) the filtered signal
is quite smooth, but there is a large delay. This of course can be problematic in real-time applications.
Additionally, for a more complex signal, the large M filter will smooth out signal features which may
not be desirable.
pf2

Partial preview of the text

Download Assignment 1 Solutions - Digital Signal Processing | EE 275 and more Assignments Digital Signal Processing in PDF only on Docsity!

E E 2 7 5 (September 14, 2008)

Digital Signal Processing & Filtering Fall Semester 2008

H O M E W O R K NO. 1 SOLUTION & COMMENTS

[2.1] X= rand(N,1) generates N samples of a random variable X that are uniformly distributed on [0,1]. (Alternatively, you can look upon the sequence generated as a realization of a random process with in- dividual samples as random variables). Using hist(X) gives you a histogram, which is a non-normalised approximation to the pdf, which shows you how good a uniform pdf you have. In problem 2.1, the signal is the same for a number of additions of noise vectors. The averaging then effectively operates on the ensemble of noise, that is, the 50 realizations, thereby smoothing the noise. The signal, which is ā€œfixedā€ is not affected. Note that you can also time averaging as in problem 2.4. Other observations: For the noise vector x, autocorrelation Rx(m) (the time-averaging one) is defined as Rx(m) =

n

x(n)x(m + n)

The MATLAB function y = xcorr(x, x) accomplishes that. Better yet, use the covariance function y = xcov(x) which is defined as

Cx(m) =

n

(x(n) āˆ’ ĀÆx)(x(n + m) āˆ’ ĀÆx)

where ĀÆx is the mean value of x. Here you see more of a ā€œdelta-functionā€ that implies decorelation of neighboring samples. So, using y=xcov(x), plot(y) gives a plot of the covariance of x and shows you how well the noise is decorrelated. Note that the white part of white noise refers to the fact that since all samples are ideally uncorrelated i.e. Rx(m) =

m x(n)x(n^ +^ m) =^ Ī“(m). The Power Spectral density^ Sx(e jω (^) ), which is the DFT of Rx(m), will be 1 for all frequencies ω ∈ Ļ€. Hence the term white noise. Note also that the pdf of white noise may be Uniform, Gaussian, Poisson or any other distribution. The whiteness and distribution are independent. Once you have white noise i.e. a flat spectrum, you can apply that noise to a filter, say a low pass filter. The output power spectral density Sy (ω) will no longer be flat. You now have colored noise.

[2.2] Generating a complex exponential sequence; plotting the real and imaginary parts. Using .01 for the real exponent,. 1 π for the imaginary exponent, amplitude of 1 and signal length of 100 we get signals as in Figures 1(a) and 1(b). That is, exponentially decreasing sinusoids.

[2.3] Generating a real exponential sequence, using real arguments.

[2.4] A MA filter is an averaging filter where the averaged portion of the input moves. That is, for example y[n] = 13 (x[n] + x[n āˆ’ 1] + x[n āˆ’ 2]) gives a 3-point MA filter. You have a M-point MA filter. This type of averaging is ā€œtime-averagingā€ (of a single time series) as opposed to averaging over an ensemble as in problem 2.1. We observe that for small M (3) the filtered signal still shows noise. For large M (20) the filtered signal is quite smooth, but there is a large delay. This of course can be problematic in real-time applications. Additionally, for a more complex signal, the large M filter will smooth out signal features which may not be desirable.

āˆ’3 0 10 20 30 40 50 60 70 80 90 100

āˆ’

āˆ’

0

1

2

3

Time index n

Amplitude

Real part

āˆ’3 0 10 20 30 40 50 60 70 80 90 100

āˆ’

āˆ’

0

1

2

3

Time index n

Amplitude

Imaginary part

Figure 1: (a) Real part, (b) Imaginary part.

[2.5] We shall examine the spectral characteristics of filters and related matters later on when we get to frequency domain analysis. The median filter works well with so-called ā€˜salt and pepper’ noise or so- called ā€œimpulse noiseā€. (That is noise which consists of outliers, that is, signal values that are extreme or out of characteristic with other signal data.) It does not work well with white noise.

[2.7] In this program cross correlation is illustrated using the convolution operation with one flipped signal, and then finding the output for various ā€œlagsā€ or ā€œshiftsā€. You can also use the function ā€œxcorr(x,y)ā€ which will give you the same answer, but for all possible shifts.

[2.8] For y[n] = s[n]+d[n] where s[n] is the signal and d[n] is the noise, consider the statistical autocorrelation function (using E for the expectation operator) which is defined as,

Ry (m) ≔ E{y[n]y[n + m]}

This equals, = E{s[n]s[n + m]} + E{d[n]d[n + m]} = Rs(m) + Rd(m) assuming that the signal and noise are uncorrelated i.e. E{s[n]d[n + m]} = 0, which often is the case. Hence the result is the sum of the two autocorrelations. In problem 2.8, the statistical (ensemble) autocorrelations are implemented as time averages. The correlation itself, as we saw earlier, is being implemented using convolution (with a flipped version of one of the signals). The autocorrelation of a sine will give a sine. Autocorrelation of noise will, ideally, give a delta-function.