0% found this document useful (0 votes)
50 views6 pages

Digital Signal Processing by John G. Pro Part17

1) Random number generators are used to simulate random phenomena like noise that are present in physical systems. They generate numbers with a uniform probability distribution that can then be transformed to model other distributions. 2) A uniform random number generator produces numbers between 0 and 1 with equal probability. These can be shifted and scaled to produce random variables with different ranges and distributions. 3) Non-uniform distributions like the normal distribution are difficult to directly map to a uniform random variable. Instead, techniques like using Rayleigh-distributed variables can generate normal distributions.

Uploaded by

Hasan Al Banna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views6 pages

Digital Signal Processing by John G. Pro Part17

1) Random number generators are used to simulate random phenomena like noise that are present in physical systems. They generate numbers with a uniform probability distribution that can then be transformed to model other distributions. 2) A uniform random number generator produces numbers between 0 and 1 with equal probability. These can be shifted and scaled to produce random variables with different ranges and distributions. 3) Non-uniform distributions like the normal distribution are difficult to directly map to a uniform random variable. Instead, techniques like using Rayleigh-distributed variables can generate normal distributions.

Uploaded by

Hasan Al Banna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

APPENDIX

Random Number
A
Generators

In some of the examples given in the text, random numbers are generated to simulate
the effect of noise on signals and to illustrate how the method of correlation can be
used to detect the presence of a signal buried in noise. In the case of periodic signals,
the correlation technique also allowed us to estimate the period of the signal.
In practice, random number generators are often used to simulate the effect of
noiselike signals and other random phenomena 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 be able to detect relatively weak signals.
By generating such noise on a computer, we are able to study its effects through
simulation of communication systems, radar detection systems, and the like 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 zero 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 0 ~ A ~ 1.
We know that the numerical output of a digital computer has limited precision,
and as a consequence, it is impossible to represent the continuum of numbers in the
interval 0 ~ A ~ 1. However, we can assume that our computer represents each
output by a large number of bits in either fixed point or floating point. Consequently,
for all practical purposes, the number of outputs in the interval 0 ~ A ~ 1 is suffi-
ciently large, so that we are justified in assuming that any value in the interval is a
possible output from the generator.
The uniform probability density function for the random variable A, denoted as
p(A), is illustrated in Fig. A.l(a). We note that the average value or mean value of
A, denoted as m A, is m A = !. The integral of the probability density function, which
1041
\ /
1042 Appendix A Random Number Generators

p(A)

~----~---L----
o 1
__ A
2
(a)

FtA)

-I"'-------------'-------A
Figure A.l o 1
(b)

represents the area under p(A), is called the probability distribution function of the
random variable A and is defined as

F(A) = i: p(x)dx (AI)

For any random variable, this area must always be unity, which is the maximum value
that can be achieved by a distribution function. Hence

F(I) = i~ p(x)dx = I (A2)

and the range of F(A) is 0 ~ F(A) ~ I for 0 ~ A ~ l.


If we wish to generate uniformly distributed noise in an interval (b, b + 1) it can
simply be accomplished 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 (A3)
which now has a mean value m B = b + !.
For example, if b = -!,
the random
variable B is uniformly distributed in the interval (-!, !), as shown in Fig A2( a).
Its probability distribution function F(B) is shown in Fig A2(b).

1
r~ I
o 1
2 2

;r
(a)

l F(B) ,

----""I'----+0----..1.
1- - - - - . B
Figure A.2 -2 2
(b)
1043
F(C)

F(C)=A
C=F-'(A)

--=----C'--+o---------i- C
Figure A.3

A uniformly distributed random variable in the range (0, 1) can be used to gen-
erate 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 FigA.3. Since 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
F(C) = A (A.4)
then
(A.S)
Thus we solve (A.4) for C, and the solution in (A.S) provides the value of C for
which F(C) = A. By this means we obtain a new random variable C with probability
distribution F(C). This inverse mapping from A to C is illustrated in Fig A.3.

EXAMPlEA.l
Generate a random variable C that has the linear probability density function shown in
Fig A.4(a), that is,

P(C)={~' 0~C~2
0, otherwise

p(C) C
"2

---+0----2-'------- C

(a)

F(C)

----l"'''''-----''------C
Figure A.4 2
(b)
I /
1044 Appendix A Random ~umber Generators

Solution. This random variable has a probability distribution function

FCC) = 1°,
~C2,
1,

which is illustrated in Fig A.4(b). We generate a uniformly distributed random variable A and
set FCC) = A. Hence
FCC) = ~C2 = A
Upon solving for C, we obtain
C=2JA
Thus we generate a random variable C with probability function FCC), as shown in Fig A.4(b).

In Example A1 the inverse mapping C = F- 1 (A) was simple. In some cases it


is not. This problem arises in trying 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 Fig AS. The probability
density function is given by

(C) = _1_ -C 2 /2(12 < C < (A.6)


P v'2iia e , -00 00

where a 2 is the variance of C, which is a measure of the spread of the probability


density function p(C). The probability distribution function F(C) is the area under
p(C) over the range (-00, C). Thus

F(C) = L: p(x)dx (A7)

p(C)

----------------~--------------c

(a)

F(C)

--------~~----~o--------------c
Figure A.S
(b)
1045

Unfortunately, the integral in (A.7) 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
R < 0
(A8)
R?: 0
is related to a pair of Gaussian random variables C and D, through the transforma-
tion
C = Rcose (A.9)
D = Rsine (AlO)
where e is a uniformly distributed variable in the interval (0. 21l'). The parameter
a 2 is the variance of C and D. Since (A8) is easily inverted, we have

F(R) =I - e-R2/2a2 =A
and hence
R = J2a 2 In[1/(1 - A)] (A.ll)
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
e=21l'B (AI2)
then from (A9) and (AlO), we obtain two statistically independent Gaussian dis-
tributed random variables C and D.

C SUBROUTINE GAUSS CONVERTS A UNIFORM RANDOM


C SEQUENCE XIN IN [0,1] TO A GAUSSIAN RANDOM
C SEQUENCE WITH G(O,SIGMA**2)
C PARAMETERS
C XIN :UNIFORM IN [0,1] RANDOM NUMBER
C B :UNIFORM IN [0,1] RANDOM NUMBER
C SIGMA :STANDARD DEVIATION OF THE GAUSSIAN
C YOUT :OUTPUT FROM THE GENERATOR
C
SUBROUTINE GAUSS 9XIN,B,SIGMA,YOUT)
PI;4.0*ATAN (1.0)
B;2.0*PI*B
R;SQRT (2.0*(SIGMA**2)*ALOG(1.0/(1.0-XIN»)
YOUT;R*COS(B)
RETURN
END
C NOTE: TO USE THE ABOVE SUBROUTINE FOR A
C GAUSSIAN RANDOM NUMBER GENERATOR
C YOU MUST PROVIDE AS INPUT TWO UNIFORM RANDOM NUMBERS
C XIN AND B
C XIN AND B MUST BE STATISTICALLY INDEPENDENT
C

Figure A.6 Subroutine for generating Gaussian random variables


I
1046 Appendix A Random Number Generators

The method described above is often used in practice to generate Gaussian


distributed random variables. As shown in Fig A.S, these random variables have a
mean value of zero and a variance a 2 • If a nonzero mean Gaussian random variable
is desired, then C and D can be translated by the addition of the mean value.
A subroutine implementing this method for generating Gaussian distributed
random variables is given in Fig A.6.

You might also like