Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform...
-
Upload
allyson-willis -
Category
Documents
-
view
226 -
download
15
Transcript of Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform...
![Page 1: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/1.jpg)
Dr. Uri Mahlab
![Page 2: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/2.jpg)
Dr. Uri Mahlab
![Page 3: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/3.jpg)
Dr. Uri Mahlab
Generation of Random Variables•Most computer software libraries include a uniform random number generator.•Such a random number generator a number between 0 and 1 with equal probability.•We call the output of the random number generator a random variable.•If A denotes such a random variable, its range is the interval o A 1
![Page 4: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/4.jpg)
Dr. Uri Mahlab
f x( ) Is called the probability density function
F(A) is called the probability distribution function
Where:
![Page 5: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/5.jpg)
Dr. Uri Mahlab
f(A)
1
0 1A
F(A)
1
0 1 A
(b)
1
2 (a)
Figure: Probability density function f(A)
and the probability distribution function F(A)
of a uniformly distributed random variable A.
Fig 1
![Page 6: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/6.jpg)
Dr. Uri Mahlab
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
Which now has a mean value
![Page 7: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/7.jpg)
Dr. Uri Mahlab
f(B)1
0B
F(B)
1
0
(b)1
2(a)
1
2
B1
2
1
2
Figure : Probability density function and the probability
distribution function of zero- mean uniformly distributed
random variable B A b
Fig 2
![Page 8: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/8.jpg)
Dr. Uri Mahlab
CC 0
A=f(C)
1
F(C) F C A
C F A
( )
( )
1
Figure : Inverse mapping from the uniformly distributed random variable A to the new random variable C
Fig.3
![Page 9: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/9.jpg)
Dr. Uri Mahlab
Example 2.1 Generate a random variable C that has the linear probability density function shown in Figure (a);I.e.,
f CC
( ),
1
2 0 C 2
0, otherwisef(C)
1
0 2 C
c
2
(a)
F(C)
1
0 2 C
1
42C
(b)
Figure : linear probability density function and the corresponding probability distribution function
Answerip_02_01
MATLAB.lnk
Fig - 4
![Page 10: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/10.jpg)
Dr. Uri Mahlab
•Thus we generate a random variable C with probability function F(C) ,as shown in Figure 2.4(b). In Illustartive problem 2.1 the inverse mapping C= (A) was simple. In some cases it is not.
Lets try to generate random numbers that have a normal distribution function.
•Noise encountered in physical systems is often characterized by the normal,or Gaussian probability distribution, which is illustrated in Figure 2.5. The probability density function is given by
F 1
Gaussian Normal Noise
![Page 11: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/11.jpg)
Dr. Uri Mahlab
Where is the variance of C, which is a measure of the spread of the
probability density function f(c). The probability
distribution function F(C) is the area under f(C)
over the range(- ,C). Thus
2
f(C)
0C
F(C)1
0
(b)
1
2
(a)
CFig 5
Gaussian probability density function and the corresponding probability distribution function.
![Page 12: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/12.jpg)
Dr. Uri Mahlab
Unfortunately,the integral cannot be expressed in terms of simple functions. Consequently the inverse mapping is difficult to achieve.
A way has been found to circumvent this problem. From probability theory it is known that a Rayleigh distributed random variable R, with probability distribution function
![Page 13: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/13.jpg)
Dr. Uri Mahlab
Is related to a pair of Gaussian random variables C and D through the transformation
have weinverted,easily
is f(R) since D. and C of variance theisparameter The
).,2interval(0 in the vaiableddistributeuniformly is where 2
![Page 14: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/14.jpg)
Dr. Uri Mahlab
Where A is a uniformly distributed random variable in the interval(0,1). Now, if we generate a second uniformly distributed random variable B and define
Then from transformation,we obtain two statistically independent Gaussian distributed random variables C and D.
![Page 15: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/15.jpg)
Dr. Uri Mahlab
MATLAB.lnk
Gngauss.m
Gaussian Normal Noise
u=rand; % a uniform random variable in (0,1) z=sgma*(sqrt(2*log(1/(1-u)))); % a Rayleigh distributed random variableu=rand; % another uniform random variable in (0,1)gsrv1=m+z*cos(2*pi*u);gsrv2=m+z*sin(2*pi*u);
![Page 16: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/16.jpg)
Dr. Uri Mahlab
Generate samples of a multivariate Gaussian random
process X(t) having a specified mean value mx
and a covariance Cx
Answerip_02_02MATLAB.lnk
Example 2.2: [Generation of samples of a multivariate gaussian process]
![Page 17: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/17.jpg)
Dr. Uri Mahlab
Example 2.3: generate a sequence of 1000(equally spaced) samples of
gauss Markov process from the recursive relation
x x wn n n 0 95 1. , n 1 2 1000, ,...,
where x and {w is a sequence of zero mean
and unit variance i.i.d. a Gaussian random variables.
plot the sequence{x 1 n 1000} as a function of
the time index n and the autocorrelation.
n
n,
0 0
}
Answerip_02_03
MATLAB.lnk
![Page 18: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/18.jpg)
Dr. Uri Mahlab
Power spectrum of random processes and white processes
A stationary random process X(t) is characterized in the frequency domain by its power spectrum which is the fourier transform of the autocorrelation function of the random process.that is,
S fx ( )R tx ( )
Conversely, the autocorrelation function of a stationary process X(t) is obtained from the power spectrum by
means of the inverse fourier transform;I.e.,
R tx ( )S fx ( )
![Page 19: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/19.jpg)
Dr. Uri Mahlab
Definition:A random process X(t) is called a white process if it has a flat power spectrum, I.e., if is a
constant for all f frequencyS fx ( )
![Page 20: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/20.jpg)
Dr. Uri Mahlab
Example 2.4:1) Generate a discrete-time sequence of N=1000 i.i.d. uniformly distributed random in interval (-1/2,1/2) and compute the autocorrelation of the sequence {Xn} defined as
R mN m
X Xx nn
N m
n m( ) ,
1
1m M0 1, ,...,
1
N mX Xn
n m
N
n m, m M 1 2, ,...,
2) Determine the power spectrum of the sequence {Xn} by computing the discrete Fourier transform (DFT) of Rx(m) The DFT,which is efficiently computed by use of the fast Fourier transform (FFT) algorithm, is defined as
S f R m ex xj fm m
m M
M
( ) ( ) /( )
2 2 1
MATLAB.lnk
AnswerMatlab: M-file
ip_02_04
![Page 21: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/21.jpg)
Dr. Uri Mahlab
Example 2.5:
compute the auto correlation Rx(t) for the random process whose power spectrum is given by
S f
NB
Bx ( )
0
2, f
0, f
MATLAB.lnk
AnswerMatlab: M-file
ip_02_05
![Page 22: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/22.jpg)
Dr. Uri Mahlab
![Page 23: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/23.jpg)
Dr. Uri Mahlab
Linear Filtering of Random Processes
Suppose that a stationary random process X(t) is passed through a liner 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.
![Page 24: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/24.jpg)
Dr. Uri Mahlab
The auto correlation function of y(t) is
In the Frequency domain
![Page 25: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/25.jpg)
Dr. Uri Mahlab
Example 2.6
suppose that a white random process X(t) with power spectrum Sx(f)= 1 for all f excites a linear filter with impulse response
h t( )
e , t
0, t 0
-t 0
Determine the power spectrum Sy(f)of the filter output.
MATLAB.lnk
AnswerMatlab: M-file
ip_02_06
![Page 26: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/26.jpg)
Dr. Uri Mahlab
Example 2.7
Compute the autocorrelation function Ry(t) corresponding to Sy(f)in the Illustrative problem 2.6 for the specified Sx(f)=1
MATLAB.lnk
AnswerMatlab: M-file
ip_02_07
![Page 27: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/27.jpg)
Dr. Uri Mahlab
AnswerMatlab: M-file
ip_02_08MATLAB.lnk
Example 2.8
Suppose that a white random process with samples{X(n)} is passed through linear filter with impulse response
h n( )
(0.95) , n
0, n 0
n 0
Determine the power spectrum of the output process{Y(n)}
![Page 28: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/28.jpg)
Dr. Uri Mahlab
Lowpass and Bandpass 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 band limited if the power spectrum Sx(f)=0 for Sx(f)>B. The parameter B is called the bandwidth of the random process
![Page 29: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/29.jpg)
Dr. Uri Mahlab
Example # 9: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.I.d. sequence of uniformly distributed random variables on the interval(-0.5,0.5 ). The lowpass filter has the impulse response.
AnswerMatlab: M-file
ip_02_09MATLAB.lnk
h n( )
(0.9) , n
0, n 0
n 0
And is characterized by the input-output recursive(difference)equation.
y y xn n n 0 9 1. , n 1 y 1 0
Compute the output sequence{yn} and determine the autocorrelation function Rx(m) and Ry(m),as indicated in problem 2.4 Determine the power spectra Sx(f) and Sy(f) by computing the DFT of Rx(m) and Ry(m)
![Page 30: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/30.jpg)
Dr. Uri Mahlab
N=1000; % The maximum value of nM=50;Rxav=zeros(1,M+1);Ryav=zeros(1,M+1);Sxav=zeros(1,M+1);Syav=zeros(1,M+1);for i=1:10, % take the ensemble average ove 10 realizations X=rand(1,N)-(1/2); % Generate a uniform number sequence on (-1/2,1/2) Y(1)=0; %should be x(1) !!!!! for n=2:N, Y(n) = 0.9*Y(n-1) + X(n); % note that Y(n) means Y(n-1) end; Rx=Rx_est(X,M); % Autocorrelation of {Xn} Ry=Rx_est(Y,M); % Autocorrelation of {Yn} Sx=fftshift(abs(fft(Rx))); % Power spectrum of {Xn} Sy=fftshift(abs(fft(Ry))); % Power spectrum of {Yn} Rxav=Rxav+Rx; Ryav=Ryav+Ry; Sxav=Sxav+Sx; Syav=Syav+Sy; end;Rxav=Rxav/10;Ryav=Ryav/10;Sxav=Sxav/10;Syav=Syav/10;% Plotting commands follow
»
![Page 31: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/31.jpg)
Dr. Uri Mahlab
•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 fo and relatively small outside of this band of frequencies.
•A random process is called narrowband if its bandwidth B<< fo
•Bandpass processes are suit for representing modulated signals.In communication the information-bearing signal is usually a lowpass random process that modulates a carrier for transmission over a bandpass communication channel. Thusthe modulated signal is bandpass random process.
![Page 32: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/32.jpg)
Dr. Uri Mahlab
Example # 10:[Generation of samples a bandpass random process] Generate samples of a bandpass random process by first generating samples of two statistically independent random processes XC(t) and XS(t) and using these to modulate the quadrature carriers cos( 2 ) and sin 2 ,as shown in figure 7.f t0
f t0
+-
Figure 7: generation of a bandpass random process
AnswerMatlab: M-file
ip_02_10
MATLAB.lnk
![Page 33: Dr. Uri Mahlab. Generation of Random Variables Most computer software libraries include a uniform random number generator. Such a random number generator.](https://reader036.fdocuments.net/reader036/viewer/2022081512/56649d955503460f94a7e63c/html5/thumbnails/33.jpg)
Dr. Uri Mahlab
N=1000; % number of samplesfor i=1:2:N, [X1(i) X1(i+1)]=gngauss; [X2(i) X2(i+1)]=gngauss;end; % standard Gaussian input noise processesA=[1 -0.9]; % lowpass filter parametersB=1;Xc=filter(B,A,X1); Xs=filter(B,A,X2);fc=1000/pi; % carrier frequencyfor i=1:N, band_pass_process(i)=Xc(i)*cos(2*pi*fc*i)-Xs(i)*sin(2*pi*fc*i);end; % T=1 is assumed% Determine the autocorrelation and the spectrum of the band-pass processM=50;bpp_autocorr=Rx_est(band_pass_process,M);bpp_spectrum=fftshift(abs(fft(bpp_autocorr)));% plotting commands follow