You are on page 1of 9

Analogue and Digital Communication Lab

(EL-323)

LABORATORY MANUAL

ENGR. IHTISHAM KHALID & ENGR. MUHAMMAD ASIM


Random Processes in MATLAB
(LAB # 10)
Student Name: ______________________________________________

Roll No: ________________ Section: ____

Date performed: _____________, 2016

____________________________________________________________________________________________________________________________________________________________

NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES, ISLAMABAD

Prepared by: Engr. M. Asim, Engr. Ihtisham Khalid Version: 2.01


Last Edited by: Engr. M. Asim, Engr. Ihtisham Khalid
Verified by: Dr. Shahzad Saleem Updated: Fall 2016
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
Lab#10: Random Processes in MATLAB
Learning Objectives:
1. Generation of Random Variables and samples of Random Processes in MATLAB
2. Power Spectrum Analysis of Random Processes and White Processes in MATLAB
3. Linear Filtering of Random Processes in MATLAB
4. Implementation of Lowpass and Bandpass Processes in MATLAB
Equipment Required:
1. PC
2. Matlab

Introduction
In this lab we will implemet methods for generating random variables and samples of
random processes in MATLAB. We begin with the implementation of a method for generating
random variables with a specified probability distribution function. Then we will analyze the
characterization of a stationary random process by its autocorrelation in the time domain and by its
power spectrum in the frequency domain using MATLAB. Because linear filters play a very
important role in communication systems, we will also implement the autocorrelation function and
the power spectrum of a linearly filtered random process. At the end of this lab we will analyse the
characteristics of lowpass and bandpass random processes using MATLAB.
Generation of Random Variables:
Random number generators are often used in practice to simulate the effect of noise like signals and
other random phenomena that are encountered in the physical world. Such noise is present in
electronic devices and systems and usually limits our ability to communicate over large distances
and to detect relatively weak signals. By generating such noise on a computer, we are able to study
its effects through simulation of communication systems and to assess the performance of such
systems in the presence of noise.
Most computer software libraries include a uniform random number generator. Such a random
number generator generates a number between 0 and 1 with equal probability. We call the output of
the random number generator a random variable. The uniform probability density function for the
random variable A, denoted as f (A ) is illustrated in Figure 2.1(a).

_____________________________________________________________________________________________
Page 2 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
We note that the average value or mean value of A, denoted as m A, is m A =1/2. The integral of the
probability density function, which represents the area under f (A ) is c=alled the probability
distribution function of the random variable A and is defined as
A
F ( A )=∫ f ( x )dx
−∞

For any random variable, this area must always be unity, which is the maximum value that can be
achieved by a distribution function. Hence, for the uniform random variable A we have
A
F ( A )=∫ f (x )dx =1
−∞

and the range of F(A) is 0 < F(A) < 1 for 0 < A < 1. The probability distribution
function is shown in Figure 2.1(b). If we wish to generate uniformly distributed noise in an interval
(b, b + 1), it can be accomplished simply by using the output A of the random number generator and
shifting it by an amount b. Thus a new random variable B can be defined as
B= A+ b

1
which now has a mean value m B =b+ . For example, if b = -0.5, the random variable B is
2
uniformly distributed in the interval (- 0.5, 0.5), as shown in Figure 2.2(a). Its probability
distribution function F(B) is shown in Figure 2.2(b). A uniformly distributed random variable in the
range (0,1) can be used to generate random variables with other probability distribution functions.
For example, suppose that we wish to generate a random variable C with probability distribution
function F(C), as illustrated in Figure 2.3.

Because the range of F (C) is the interval (0,1), we begin by generating a uniformly distributed
random variable A in the range (0,1). If we set
_____________________________________________________________________________________________
Page 3 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
F ( C )= A 2.1 ¿
C=F−1 A 2.2 ¿
Thus we solve the 2.1) for C, and the solution in 2.2) provides the value of C for which F ( C )= A.
By this means we obtain a new random variable C with probability distribution function F(C). This
inverse mapping from A to C is illustrated in Figure 2.3.
Problem 01:
Generate a random variable C that has the linear probability density function shown in Figure
2.4(a); that is,

Power Spectrum of Random Processes and White Processes:


A stationary random process X (t),is characterized in the frequency domain by its
power spectrum S x ( f ),which is the Fourier transform of the autocorrelation
function R x ( τ ), of the random process; that is,

S x ( f )= ∫ Rx ( τ) e− j 2 πfτ dτ
−∞

Conversely, the autocorrelation function R x (τ ) can also be obtained



R x ( τ )=∫ S x ( f ) e j 2 πfτ df
−∞

In modeling thermal noise that is generated in electronic devices used in the implementation of
communication systems, we often assume that such noise is a white random process. Such a process
is defined as follows.

_____________________________________________________________________________________________
Page 4 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
Definition: A random process X (t) is called a white process if it has a flat power spectrum—that is,
if S x ( f ) is a constant for all f . As indicated above, the importance of white processes stems from the
fact that thermal noise can be closely modeled as spectrally constant over a wide range of
frequencies . Also, a number of processes that are used to describe a variety of information sources
are modeled as the output of LTI systems driven by a white process. We observe, however, that if
S x ( f )=C for all f , then
∞ ∞

∫ S x ( f ) df = ∫ C df =∞
−∞ −∞

Thermal noise, although not precisely white, can be modeled for all practical purposes as a white
N
process. The power-spectral density of thermal noise is usually given as S x ( f )= 0 and is
2
sometimes referred to as the two-sided power-spectral density, emphasizing that this spectrum
extends to both positive and negative frequencies. We will avoid this terminology throughout and
simply use power spectrum or power-spectral density. For a white random process X(t) with power
N
spectrum S x ( f )= 0 , the autocorrelation function R x ( τ ) is
2

j 2 πfτ N 0 ∞ j 2 πfτ N
R x ( τ )= ∫ S x ( f ) e df = ∫ e df = 0 δ (τ )
−∞ 2 −∞ 2
where δ (τ ) is the unit impulse. Consequently, for all τ ≠ 0, we have R x ( τ )=0 that is, if we sample a
white process at two points t 1∧t 2(t 1 ≠ t 2), the resulting random variables will be uncorrelated. If,
in addition to being white, the random process is Gaussian, the sampled random variables will be
statistically independent Gaussian random variables.

Problem 02:
Generate a discrete-time sequence of N =1000 i.e. uniformly distributed random numbers in the
interval (-0.5,0.5) and compute the estimate of the autocorrelation of the sequence {Xn},

Also, compute the power spectrum of the sequence {Xn} by evaluating the discrete
Fourier transform (DFT) of ^
R x (m) ,The DFT, which is efficiently computed by use of
the FFT algorithm, is defined as

_____________________________________________________________________________________________
Page 5 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
Problem 03:
A bandlimited random process X(t) has the power spectrum

Compute the autocorrelation R x ( τ ), for the random process whose power spectrum is given above.

Linear Filtering of Random Processes:


Suppose that a stationary random process X (t) is passed through a linear time-invariant
filter that is characterized in the time domain by its impulse response h(t) and in the
frequency domain by its frequency response

H ( f ) =∫ h(t )e− j 2 πft dt
−∞

It follows that the output of the linear filter is the random process

Y (t )=∫ X (t) h(t−τ) dτ
−∞

The mean value of Y(t) is


m y =E [Y (t)]
¿ m x H (0)
where H(0) is the frequency response H(f) of the filter evaluated at f = 0. The autocorrelation
function of Y(t) is
R y ( τ)=E[Y (t) Y (t+ τ )]
In the frequency domain, the power spectrum of the output process Y(t) is related to the power
spectrum of the input process X(t) and the frequency response of the linear filter by the expression
S y ( f )=S x ( f )¿ H ( f )∨¿2 ¿

Problem 04:
Suppose that a white random process X(t) with power spectrum S x (f ) = 1 for all f excites a linear
filter with impulse response

_____________________________________________________________________________________________
Page 6 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________

Determine the power spectrum S y ( f ) of the filter output.

Problem 05:
Compute the autocorrelation function R y (τ) corresponding to S y ( f ) in Problem 04 for
the specified S x (f ) = 1.
Problem 06:
Suppose that a white random process with samples {X{n)} is passed through a linear filter with
impulse response

Determine the power spectrum of the output process {Y (n)}.

Lowpass and Bandpass Processes:


Just as in the case of deterministic signals, random signals can also be characterized as lowpass and
bandpass random processes.
Definition: A random process is called lowpass if its power spectrum is large in the vicinity of
f =0 and small (approaching 0) at high frequencies. In other words, a lowpass random process has
most of its power concentrated at low frequencies.
Definition: A lowpass random process X(t) is bandlimited if the power spectrum S x ( f )=0 for
|f |> B. The parameter B is called the bandwidth of the random process.
Definition: A random process is called bandpass if its power spectrum is large in a band of
frequencies centered in the neighborhood of a central frequency ± f 0 and Bandpass processes are
suitable for representing modulated signals. In a communication system, the information-bearing
signal is usually a lowpass random process that modulates a carrier for transmission over a
bandpass (narrowband)
communication channel. Thus the modulated signal is a bandpass random process. As in the case
of deterministic signals, a bandpass random process X(t) can be represented as
X (t)=X C ( t ) cos ( 2 π f 0 t )− X S ( t ) sin ( 2 π f 0 t )

_____________________________________________________________________________________________
Page 7 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
where X C ( t ) and X S ( t ) are called the in-phase and quadrature components of X(t). The random
processes X C ( t ) and X S ( t ) are lowpass processes.
Theorem: If X(t) is a zero-mean, stationary random process, the processes X C ( t ) and X S ( t ) are also
zero-mean, jointly stationary processes.The autocorrelation function of the bandpass process X(t)
is expressed in terms of the autocorrelation function Rc (t) and the cross-correlation function Rcs
(t) as
R x ( τ )=RC ( τ ) cos ( 2 π f 0 τ )−R CS ( τ ) sin ( 2 π f 0 τ )

Problem 07:
Consider the problem of generating samples of a lowpass random process by passing a white noise
sequence {Xn} through a lowpass filter. The input sequence is an i.e. sequence of uniformly
distributed random variables on the interval (- 0.5, 0.5). The lowpass filter has the impulse response

and is characterized by the input-output recursive (difference) equation


y n=0.9 y n −1 + x n , n≥ 1 , y −1=0
Compute the output sequence { y n } and determine the estimates of the autocorrelation functions
^
R x (m) and ^ R y (m). Determine the estimates of the power spectra ^S x ( f ) and ^S y ( f ) by computing the
DFT of ^ R x (m) and ^ R y (m).

Problem 08:
Generate samples of a Gaussian bandpass random process by first generating samples of two
statistically independent Gaussian random processes Xc(t) and Xs(t) and then using these to
modulate the quadrature carriers cos 2 π f 0 t and sin 2 π f 0 t , as shown in below given figure

Student's feedback (Try giving useful feedback, e.g. did this lab session help you in learning, how to
improve student's learning experience, was the staff helpful, etc):
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________________________
Page 8 of 9
Lab #
Analogue and Digital National University Roll No: __________
Communication Lab
(EL323)
of Computer and Emerging Sciences
Islamabad Fall 2016
10
____________________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________

Student's Signature: _________________________________

Correctness of

TOTAL
AWARDED

Attitude

Neatness

Conclusion
Originality
Initiative
MARKS

TOTAL 10 10 10 20 20 30 100

EARNED

Lab Instructor's Comments:_______________________________________________________


_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________

Lab Instructor's Signature: _________________________________

_____________________________________________________________________________________________
Page 9 of 9

You might also like