Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views15 pages

CH 7

The document discusses the generation of random variates, focusing on methods to produce independent random series with specific statistical properties. It outlines various techniques for generating uniformly distributed random numbers, including the mid-square, mid-product, GPSS algorithm, and multiplicative congruential methods, emphasizing the importance of reproducibility and speed in simulations. Additionally, it addresses the generation of normal random numbers and the use of transformation methods to achieve desired distributions in hydrological modeling.

Uploaded by

riwajbasnet9
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)
17 views15 pages

CH 7

The document discusses the generation of random variates, focusing on methods to produce independent random series with specific statistical properties. It outlines various techniques for generating uniformly distributed random numbers, including the mid-square, mid-product, GPSS algorithm, and multiplicative congruential methods, emphasizing the importance of reproducibility and speed in simulations. Additionally, it addresses the generation of normal random numbers and the use of transformation methods to achieve desired distributions in hydrological modeling.

Uploaded by

riwajbasnet9
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/ 15

13

Generation ofRandom Variates


13.1. INTRODUCTION
As we have seen in the previous chapter, once a proper model
is identified and its parameters est~mated the first step in the
generation ofsynthetic flow sequences is to produce the independent
random series Zt with a specific mean and a specific variance and
drawn from a specified distribution. This random serie~ should not
exhibit serial correlation for any lag. Fortunately the random num-
bers of any distribution can be obtained by a transformation from
the random numbers of uniform distribution. We shall therefore
first discuss the methods of generating uniformly distributed num-
bers and later show how these can be transformed into random
numbers of other distributions. As already described a uniformly
distributed variable is the one for which each value in a given range
(say 0 to 1) is equally likely.
Strictly speaking random numbers can be obtained only from
random processes, since the word random implies that the numbers
obtained are unpredictable. Various mechanical, electrical and
electronic devices have been built in the past to produce such
numbers. These methods include experimentation with numbers
drawn from a well-shaken stack of numbered chits, selecting num-
bers at random from telephone directories, use of an electronic
roulette wheel etc. However, there are number of disadvantages
associated with the use of these methods. They are
(i) Nature tends to be systematic
(ii) The equipment tends to be cumbersome and difficult to
maintain, and
(iii) It is impossible to repeat a simulation using the same set
of random numbers.
The last point· is a very important one. This is because a
highly desirable feature of simulation models is that one should be
able to repeat the simulation process changing only one exogenous
variable and keeping everything else constant. This requires the
231
232 STOCHASTIC HYDROLDGY

ability to generate exactly the same sequence of random numbers


over and over again. When we are using a computer to generate the
flows, we could store a table of random numbers on a disc or tape
and use them whenever we want. But they consume considerable
core storage depending on the magnitude of the problem and also
the retrieval of random numbers from the memory is a delayed
process. So, from the view point of simulation on a fast digital
computer, the sequence of random numbers produced by any
method should satisfy the following conditions, i.e., it should be
(i) Capable of being generated at high speed.
(ii) Reproducible.
(iii) Non-repeating for any specified length (without peri-
odicity).
(iv) Statistically independent.
(v) Needing a mi.nimum amount of core storage.
(vi) Uniformly distributed.

To satisfy the aforestated requirements, many techniques


have been suggested which use some form ofthe recurrence relation~
ship. Since the numbers that are generated by means of an algo~
rithm based on any recurrence relati<?nship can be predicted, they
are called pseudorandom numbers. If·these pseudo-random num~
bers satisfy the other tests of randomness they can be accepted as
random numbers.

13.2. UNIFORMLY DISTRIBUTED RANDOM NUMBERS


An algorithm for generating pseudorandom sequence of num-
a
bers is commonly called random number generator. There are
many algorithms for generating random numbers, differing from
one another in the extent to which they exhibit the desirable
properties outlined earlier.
Mid-square technique. One of the earliest techniques for
the generation of pseudorandom n'umbers is' the mid-square techni-
que. In this method the kth random number of 2d digits is obtained
by squaring the (k - l)th random number to produce a number of
4d digits and by selecting the middle 2d digits from the numbe.r so
produced. To initiate the generation we require a 2d digit which is
called the random seed or simply the seed. If the seed Uo is taken as
5069, for example, then the first random number Ut is obtained by
squaring Uo and taking the middle 4 digits. Thus
uo2 = (5069)2 = 25694761 and Ut = 6947.
GENERATION OF RANDOM VARIATES 233

Proceeding in a similar way, we get the chain as u2 = 2608,


Ug = 8016, U4 = 2562, and so on. This scheme has certain
deficiencies. In the chain if a number 0000 appears, then the scheme
terminates. Also if the seed is not selected properly it may lead to
very short cycles.
Mid-product technique. Another technique which was
tried was the mid-product technique. In this method the hth random
number is taken as the central 2d digits of the product of (h - l)th
and (/l - 2)th random numbers, and requires two initial numbers
each of 2d digits to initiate the generation procedure. The mid-
product .~echnique also has the same disadvantages as the mid-
square technique.
GPSS algorithm. Another commonly used random-number
generator ;having good statistical properties is the GPSS algorithm.
The GPSS generator gets its name from General Purpose System
Simulator. The idea of this algorithm can best be illustrated by an
example using decimal integers, although it is actually carri~d out
using binary numbers on a computer. Suppose, for the sake of
example, that it is desired to generate random number Uk in the
range 0000 to 9999. We begin with a multiplies m, which is
fIXed and a seed ro. Let m = 5167 and 1"0 = 3729. These are
multiplied together to produce a product having eight digits. That
is, mro =5167 x 3729 = 19267743. The middle 4 digits of this product
are used to form the first random number Ut and the right most 4
digits are used as rl. Thus Ul =2677 and 1"1 = 7743. Next the product
of mrl is formed, its middle 4 digits are used as the second random
number U2, its right most 4 digits are used as 1"2, and so forth. Later
a decimal is put is front of each random number to get the sequence
of random numbers in the range 0 to 0.9999.
The multiplicative Congruential method. Improve-
ments over the mid-square and mid-product technique were incor-
porated in the multiplicative congruential method which is based
on the recursion-formula
Uk = (a Uk-l) mod m ... (13.1)
where the parameter a is called the multiplier, the parameter m is
called the modulus and starting number UQ is called the seed. The
notation "mod m" in this formula refers to an integer division. That
is, x mod m = remainder left over after .dividing x by m. Eq. (13.1)
can also be written in the form
• Uh = all Uo mod m ... (13.2)
For this reason, this method is also known as the power
residue method. The sequence of random numbers generated by the
234 STOCHASTIC HYDROLOGY

congruential method will be in the range 0 to (m - 1) and will


eventually be repeated. The period of repetition will always be less
than m. So m should be chosen as tne largest value that can be
conveniently used.
If the multiplicative congruential generator is programmed
on a binary computer the choice of the various constants should be
as follows
m = 2b , where b is the number of bits per word
a = 8t ± 3, t is any integer ~ 0, and
Uo = any odd integer.
This choice provides the maximum period of 2b - 2 random
numbers in the range 0 to 2 b . By dividing every number with 2 h , the
chain provides the random numbers in the range 0 to 1. When the
multiplicative congruential generator is programmed on a decimal
computer, the choice is
m = 10d , where d is the number" of digits per word
a = 200t + p, where t is any integer ~ 0, andp is a number
from the set of 32 integers given by
±{3,11,13,19,21,27,29,37,53,59,61,67,69,77,83,91}
Ut) = any number not divisible by either 2 or 5.
This choice provides a maximum period of (~) . 10d-2, if d ~ 4.
Again, by putting decimal before every number, we get a chain of
uniformly distributed random numbers in the range 0 to 1.
Mixed congruential method. This method is also known
as linearcongruential method. The recursion formula in this method
is given by
Uk = (a Uk-l + c) mod m ... (13.3)
where the number c is called the increment and a, m and Uo retain
.the same names as in the multiplicative congruential method.
Improved statistical properties of the sequence can be obtained in
the mixed congruential method compared to multiplicative con-
gruential method.
The multiplicative generator produces a sequence of random
numbers whose period is always less than rn, whether it is imple-
mented 6n a binary or decimal computer. Whereas in the mixed
congruential method when a, c and m are chosen according to the
conditions given below, a sequence ofm pseudorandom numbers in
the range 0 to (m - 1) can be generated before the sequence begins
to repeat.
GENERATION OF RANDOM VARIA'fES 235

Binary computer Decimal computer


m =2
b m = 10d
c = any odd integer c =any integer 'not divi-
sible by either 2 or 5
a mod 4 =1 a mod 20 = 1
Un = any integer so that Un = any integer so that
Os Uo s m Os Un s m
The selection of a and c in accordance with the above
specifications implies that all integers less than m will appear before
the seed appears. In order that the sequence of random numbers
generated is independent of internal serial cor~elation, the addition-
al specifications imposed on a and care
a=w
m
c=2
Finally the uniform random numbers in the range 0 to 1 may
be obtained by dividing the sequence by m.
In order to reduce the serial dependence in the series, a
second sequence of random numbers using the recursion equation
u,/ = (a' Uk-l' + c') mod m'
and the seed uo' is generated and dividing the second sequence by
rn' it is combined alternately with the first sequence.
Testing the random number sequence. The chi-square
test may be performed to ascertain whether the generated sequence
of numbers follow uniform distribution or not. Treating the
generated sequence as a time series one can construct the cor-
relogram for s~fficiently large number of lags and the corresponding
spectral density function and test them for independence byobtain-
ing the tolerance limits as per the procedures described elsewhere
in the text. Experience has shown that the sequence of random
numbers generated by mixed congruential method passes most of
the tests for independence.
Example 13.1. Ge'nerate a sequence of 12 uniformly dis-
tributed random numbers of 5 digits using the mixed cottgrtMlJ.tial
technique. Choose the appropriate values for the constants a, c an.d
m.
Sol. In accordance with the stipulations on the 9hoice of the
parameters given for mixed congruential method, the parameters
are chosen as given below.
m = 10 5 = 100000 ; a = 321
236 STOCHASTIC HYDROLDGY

c = 50001 ; and Un = 38975


Then UI = (321 Uo + 50001) mod 100000
= (321 x 38975 + 50001) mod 100000
=12560976 mod 100000 = 60976
U2 = (321 x UI + 50001) mod 100000
= (321 x 60976 + 50001) mod 100000
= 19623297 mod 100000 = 23297
Continuing the chain, we get
Ug = 28338, U4 ="46499, U5 = 76180,
lf6 = 03781, U7 = 63702, Us = 98343,
Ug = 18104, UIO = 61385, UII = 54586,
and Ul2 = 72107
Now, we can get uniform random numbers in the range 0 to
1 by assigning a decimal before every number. Thus, a sequence
0.60976, 0.23297,0.28338,0.46499,0.76180,0.03781, }
{ 0.63702,0.98343,0.18104,0.61385,0.54586,0.72107
constitutes uniformly distributed random numbers in the interval
o to 1.
Example 13.2. Test the sequence of random numbers gene-
rated in the above example for randomness.
Sol. Since the sample is very small we cannot conduct the
frequency test. However, if the first and second moments about the
origin are approximately equal to ~ and*, respectively, then we can
accept that the sample is from uniform distribution.
12
First moment = Mean = u = 112 2: Uj

i = 1

= 6.0;:98 = 0.5060816 =0.50


12
Second moment
_-l ~ .2 _ 3.9047925
- 12 LJ Ul - 12
i =1
=0.3253993 =0.3333
Therefore we consider this sequence to be a good sample from
uniform distribution.
Regarding the internal serial correlation, the sequence
generated here is too small to construct a correlogram. However, the
first and second serial correlation co-efficients obtained from Eq. (9.8)
are found to be - 0.303 and - 0.256 respectively. The limits at 5%
GENERATION OF RANDOM VARIATES 237

tolerance level computed from Eqs. (9.9) and (9.10) for the first serial
correlation coefficient are - 0.654 and 0.473 respectively. Similarly
the tolerance limits for the second serial correlation coefficient are
- 0.688 and 0.488 respectively. .
Since the estimated first and second autocorrelation co-effi-
cients are falling well with in their corresponding tolerance limits
we can say that the generated sequence is free from internal cor-
relation.

13.3. GENERATION OF NORMAL RANDOM NUMBERS


Generation of uniform random numbers alone is seldom
required in hydrology as many variables such as annual run off and
annual precipitation may follow normal distribution and variables
measured on a seasonal basis are generally skewed. So, in the
generation of hydrologic sequences we often require normal random
numbers or random numbers in mQdified formf; to have the desired
skewness. Therefore, we shall now discuss the methods of generat-
ing normal random numbers. We have already seen that a random
variable X = ~ + a Z follows a normal distribution with mean ~ and
standard devi~tion, ll, if Z is a standardised normal variable. Thus
it is sufficient if we discuss the generation of standardised normal
numbers with mean 0 and variance 1. Fortunately, the random
numbers withN(O, 1) can be generated very easily using anyone of
the following nlethods. .
The Inverse Transformation Method. If Z is a stand-
ardised normal variable its cumulative distribution functionF(z) is
given by .

F(z) =--
1
(2i[
I
-:.0
Z
e- t 2/2 dt.

where t has been used as a dummy variable to avoid confusion with


the limit of integration. If we define a new random variable U such
-that U = F(z), and if h(u) is the probability density function of U,
then we can obtain h(u) using the principle of derived distribution
explained in Sec. 2.9 from the relation.
h(u) du = f(z) dz
It may be noted that U = F(z) is a one to one non-decreasing
function. Also when z =- 00, U =F(- (0) = 0, and when z = 00,
U =F(oo) = 1.
In other words while the range ofz is - 00 to OC, the correspond-
°
ing range of U is to 1. Therefore, we have
dz f(z)
h(u) = fez) dit = (du/dz) .
238 STOCHASl1C HYDROLOGY

But since U = F(z), we ha~e that du/dz = f(z). Hence


f(z)
h(u) = f(z) = 1.
This means that U is uniformly distributed ever the range 0
to 1 with a constant ordinate equal to 1 as its probability density
function.
With this result in view, a sequence of normally distributed
random numbers may easily be generated by first generating a
sequence of uniformly distributed random numbers and then ob-
taining the normal random numbers Zj corresponding to each Uj such
that Ui =F(zj) or Zi =F- 1(Uj), where ~l is called the inverse function.
This is the reason why this method is called inverse transform.ation
method. The use of this method is somewhat constrained due to the
fact that the function F(z) is an intractable integral.
One approach would be to have the cumulative distribution
function F(z) tabulated at specified points and to arrive at the values
ofz situated in between these values by using a linear or polynomial
interpolation. This procedure is known as table lool?, up and hence,
this method is also called Table looh-!-lp method. Because the exten-
sive tabulation of F(z) and the interpolation subroutines consume a
lot of computer memory and time, other methods have been sought
for the generation of normal random numbers, which are described
below.
The central limit theorem method. Let U b lI2 , ...... , Um
be m· independent and uniformly distributed variables each in the
range 0 to 1. Then each variable has a mean equal to 0.5 and
variance equal to 1/12. Let us define a new random variable X such
thatX =Ut + U2 + + Urn' Then according to central limit theorem,
for m large, X will follow normal distribution with mean given by
~x = ~u 1 + ~U.2 +
·
+ ~um an d varIance .
given by Ox 2 = 0UI2 + 0U22 + .
+ Du:. Since J-luI = ~U.2 = ~ ~um = 0.5 and ou~ = au~ = = all:,
= 1/12, X will follow normal distribution with mean equal to 0.5 m
and variance equal to m/12. Ifwe define Z =(X -m/2)/V(m/12) , then
Z will follow normal distribution with mean 0 and variance 1.
We can therefore obtain a chain of standardised normal
random numbers 'Zj from a chain of uniformly distributed random
numbers Ui from the following equation.
rn
L (Uh - 0.5m.)
i-I
Zj = v(m/12) j = 1,2, . ... (13.4)
GENERATION OF RANDOM VARIATES 239

where h = (j - l).rn + i. Thus to generate n normal numbers by this


method, one needs to generate (n x m) uniform random numbers.
The choice of m becomes a decision between the increased cost
of generating large number of uniformly distributed random num-
bers and the corresponding nearness ofz to normal distribution. For
most purposes, th,~ choice of rn = 6 or m = 12 is made because of the
corresponding computational simplicity.
Form = 6

Zj =[ .± u" -
l == 1
3 ] . V2 ... (13.5)

where h = 6(j - 1) + i
For m. = 12
12
Zj =: ~ (Uk - 6) ... (13.6)
i =1
where h = 12(j - 1) + i.
It has been observed that m = 12 is too small to yield a
reasonable normal approximation. Another disadvantage of this
method is that the tails of the normal distribution are not well
represented.
Box-Muller method. The third and more exact method of
generating normal random numbers known as the Box-Muller
m.ethod is now described.
Let ZI and Z2 be two independently and normally distributed
random variables each with mean 0 and variance 1. Then the joint
probability density function for ZI and Z2 at any point (Zb Z2) in the
Eucledian plane is given by
q> (Zb Z2) =f(zl) f(Z2)
__1_ - Z12/2 _1_ - Z22/2
- (2i[ e . I2it e
1 2 2
or th.
't'
(z
I,
Z)
2
=-2rc e- (z 1 + Z2 )/2 ...(13.7)

Thus, the outcome of the underlying experiment produces a


random point or a random vector (ZI, Z2) in the Eucledian space of
two dimensions. Such a random point might be represented as well
in polar coordinates (R, 8) constituting the transformation of the
random variables ZI and Z2 according to
Zl = R cos e ... (13.8)
Z2 =R sin e ... (13.9)
240 STOCHASllC HYDROLOGY

The joint probability density function for the random vari-


ables Rand 0, according to the principle of multivariate derived
distributions explained in Section 2.9, then becomes

g(r, 0) = <l> Cr cos 0, r sin 0) I aa(;,~: ~~) I


i)zl ()z]

where I iJ iJ(r,
(z],
Z2) I = det;;;:z ~O =det [ C?S 0 - r sin 8 ]
0)' i) 2 ()~~2 SIn e r cos 8
ar ae
=r cos 2 8 - (- r sin2 0) = r
g(r, 0) = ~ e- (r cos H + r'1. sin 0)/2
L L L

2n:
r '1./
g(r, 8) = 21t "e- r 2 ... (13.10)

From this joint probability density function, the marginal


density function for 8 is evaluated as

((8) =f oo
g(r, 8) dr
fX
= ~ e- r'1./ 2 dr
r = 0 7· = 0 21t

=~ [ 1 _ e- r'1. /2 ]X 1
21t I 0 - 21t
1
{(8) = 21t 0 S 8 S 21t }
... (13.11)
=0otherwise
It means that 8 has a uniform distribution in the range 0 to 21t.
Similarly, the marginal density function for R becomes

h(r) =
2Jt
g(r, 8) de =f2.i"T -r 2
e- r /2 de = re- r 2 /2•
fo 0 2Jt
2 •
17,(1") = re- r /2 r ~ 0 } ... (13.12)
=0otherwise
The distribution for R given by Eq. (13.12) is known as
Rayleigh distribution. Noteworthy is the result that the random
variables Rand e are also independently distributed since
g(r, 8) = ((e) . h(r) for all coo~dinates (r, 8).
GENERATION OF RANDOM VARIATES 241

Hence, if one can generate random variables e and R having


the respective distributions given by Eqs. (13.11) and (13.12), then
the transformations ZI = R cos e and Z2 = R sin e will yield
independently distributed standardised normal variates ZI and Z2.
The variable R with the probability density function given by
Eq. (13.12) can be easily generated via the cumulative distribution
transformation (or the inverse transformation). The cumulative
distribution function of R is given by

H(r) = f; h(t) dt = f; 2
te- t /2 dt

= f; e- t
2
/2

2
d '( ; ) = [ 1 - e- t
2
/2 I
H(r) = 1 - e- /2 r ... ,13.1'3)
If U I is a uniformly distributed random variable in the range
o to 1, then
2
UI = H(r) = 1 - e- r /2
.
That IS, R =[- 21n (1- UI)] 1/2 ... (13.14)
is the variable with required Rayleigh distribution. Similarly if U 2
is another uniformly distributed random variable in the range 0 to
1, then
e = 231: U2 ... (13.15)
will be distributed uniformly in the range 0 to 2n:. Therefore, the
variables defined by
Zl =R cos e =[- 2 In (1 - U 1)] 112 cos (21tU2) }
· e = [.- 2 In (1 - U I )] 112 SIn:7t
Z 2 = R SIn . (2 U)
2
... (13.16)
will be two independently distributed standardised normal vari-
ables.
If U is unifonnly distributed in the interval (0, 1), then (1 - U)
is also uniformly distributed in the same internal (0, 1). Hence some
computational advantage may be gained by writing Eq. (13.16) in
ilie~m .
112 .
Zl = (- 2 In Ul) 112 c~s (2:n: U 2) } ... (13.17)
Z2 =(- 2 In U I ) SIn (2n: U2 )
Thus, we can generate a chain of standard normal random
numbers from a chain of uniform random numbers taking the
uniform random numbers in pairs each time from the following
~quations.
Zi =[- 2 In (1 - Ui)] 112 cos (2n: Ui+l) }
... (13.18)
Zi+I =[- 2 In (1 - Ui)] 112 sin (2n: Ui+I)
242 STOCHASTIC HYDROLOGY

We prefer to use the form ofEq. (13.16) because it is possible


that uniform random number Ui may take a value of zero in which
case its logarithm becomes infinity and the computer gives overflow
error when we use the form of Eq. (13.17). Please note that Ui will
not take a value of 1. It may tal~e a value of 0.99999 .
Example 13.3. Obta i f1. the chain ofnorm.al random. numbers
using the table looh-up method corresponding to the chain ofuniform.
random num.ber of Example 13.1.
Sol. Corresponding to every random number Uj o~ the chain,
a normal random number Zi is obtained s'l:lch that F(z;) = Ui, using
linear interpolation from the CDF table of Normal distribution given
in Table A-I of the Appendix. For example, consider UI = 0.60976.
From the table, we have that when
z = 0.26, F(z) = 0.6026
and when z = 0.27, F(z) = 0.6406
by linear interpolation when z = 0.26188, we get
F(z) = 0.60976
Z1 = 0.26188.

Similarly, all o"ther normal random numbers are obtained


and tabulated below.
Table 13.1. Normal random numbers from
Table look-up method
1 = ~-rl
u·1 Zi =V u·1 Zi

(Ui) (Ui)

1 0.60976 0.26188 7 0.63702 0.35058


2 0.23297 - 0.71956 8 0.98343 2.15049
3 0.28338 - 0.57487 9 0.18104 - 0.91138
4 0.46499 - 0.08778 10 0.61385 0.28934
5 0.76180 0.71113 11 0.54586 0.11515
6 0.3781 - 1.77671 12 0.72107 0.58698

The reader may verify that the mean and standard deviation
of these normal random numbers are 0.033 and 0.94, respectively,
which are approximately equal to 0 and 1. The reader may also note
that this sequence of normal random numbers has been used in
Examples 11.1 and 11.4 while generating the synthetic streamflows.
Example 13.4. Obtain two random normal nuntbers from. the
'sequence ofuniform random numbers ofExample 13.1 using central
limit theorem.
GENERATION OF RANDOM VARIATES 243

Sol. Zl = [.± 1, -1
Ui - 3] V2

= (2.39071 - 3) V2
=- 0.60929 V2 =- 0.8617.
Z2 = .2 12
Ui -
]
3 V2
[ 1, =7

= (3.68227 - 3) V2
= 0.68227 V2 = 0.9649.
Example 13.5. Using the sequence of uniform random n.um-
bers ofExample 13.1 in pairs, obtain the sequence ofnormal ran.dom
nllmbers employing the ~ox-Mullermethod.
Sol. The required computations are shown in Table I3.?
"
Table 13.2. Normal random numbers using
Box-Muller Method

U2 {- 2ln 21tU2
(1 - 1/.1)]112

0.60976 0.23297 1.37185 1.46379 0.10680 0.99428 0.14651 1.:36400


0.28338 0.46499 0.81634 2.92162 - 0.97590 0.21820 - 0.79667 0.17812
0.76180 0.37810 1.69390 2.37567 - 0.72074 0.69320 -1.22086 1.17421
0.63702 0.98343 1.42:366 6.17907 0.99458 - 0.10393 1.41594 - 0.14796
0.18104 0.61:385 0.63201 3.85693 - 0.75487 - 0.65587 - 0.47708 - 0.41452
0.54586 0.72107 1.25646 4.53062 - 0.18077 - 0.98352 - 0.22713 - 1.23575

Thus, the sequence {0.14651, 1.364, - 0.79667,0.17812,


-1.. 22086,1.17421,1.41549, - 0.14796, -"0.47708, - 0.41452,
- 0.22713, - 1.23575}
constitute a chain .of normal random numbers. The reader may
verify that this sequence has a mean of 0.02 and a standard devia-
tion of 0.9253.

13.4. RANDOM NUMBERS OF OTHER DISTRIBUTIONS


Sometimes random numbers following distributions other
than normal may be required. The widely used method is the method
of inverse transformation. This method can be used to transform
uniformly distributed random numbers into random numbers ofany
distribution as long as the inverse, F- 1, of the desired distribution
can be found analytically or approximately numerically.
244 STOCHASTIC HYDROLOGY

The expressions given below may be used to obtain the


random numbers following specified distributions. Only a few im-
portant cases are indicated. In these expressions u stands for
uniformly distributed random number over the range 0 to 1 and z
denotes the normal random number with zero mean and unit
variance. Where more than one value are required, a typical value
is designated as Ui or Zi' All values are taken independently of one
another. y denotes the random number of desired distribution.
Exponential Distribution. If Y is following an exponential
distribution with p.d.f.
f(y) = 'Ae- A(y - Jl) , \vith fl S Y s x,
then the-random numbers of this distribution can be generated from
1
y = -~ In (l-u) + fl ... (13.19)

Gamma Distribution. Ify is following a gamma di stribution


with p.d.f.
f(y) = Al) e- Ay y1 1 - 1 with 0 S Y S x
[1)
and 1) an integer then, the random num~ers following this distribu-
tion are generated from
11
1
y =- ~ ~ In (1 - Ui) ... (13.20)
i == 1
Log-Normal Distribution. If Y is following log-normal
distribution with p.d.f. 2 .
1 (lny - Jl)
f(y)= _~e 202 withOsysx
yuv 211:
Then the random numbers following this distribution are generated
from
y = e Oz + Jl ... (13.21)
Binomial Distribution. If Y is following binomial distribu-
tion with p.m.f.
p(y) = (~ )p'" (l_p)n~; withy = 0,1,2, ,n

n
then y = ~ hi ... (13.22)
i-I
will give the random numbers following this distribution, where
hi = 0, ifui <P,
and hi = 1 if Ui ~ P ;
i = 1,2, , n.
GENERATION OF RANDOM VARJATES 245

PoissionDistribution. IfYis following Poisson distribution


withp.m.f.
e- A IJ' .
p(y) =- , - ,y = 0,1,2, .
y.
then the random numbers Iollowing this distribution can be obtained
from
y = Il ... (13.23)
where h is the lowest integer such that
h+l
2: - i1 In (1 - Ui) > 1
i = 1
All these expressions are obtained through the appropriate
cumulative distribution functions of the corresponding distribu-
tions.

EXERCISES
13.1. Explain the mixed congruential method of generating uniformly
distribution random numbers in the range 0 to 1.
13.2. Describe the methods of gener~ting standard normal random
numbe~s by inverse transform and central limit theorem.
13.3. Describe the Box-Muller method of generating normal random
numbers.
13.4. How do you select the parameters in mixed congruential algorithm
for generating uniformly distributed random numbers to ensure
minimum serial correlation and maximum periodicity.
13.5. Generate a chain of 12 uniformly distributed random numbers in
the range 0 to 0.99999 using the mixed congruential method. The
increment, multiplier, modulus and the seed may be taken as
54733,321,105 and 42875 respectively. Hence obtain two normal
random numbers ofN(O, 1) using the central limit theorem method.
13.6. Obtain 12 standard normal random numbers using the 12 uniform-
ly distributed random numbers obtained in Exercise 13.5 and
table-look up method. Compute mean, standard deviation and first
serial correlation coefficient for this chain.
13.7. Using the uniformly distributed random nwnbers of Exercise 13.5
and Box-Muller method, generate 12 standard normal random
numbers. Compute mean, standard deviation and first serial cor-
relation coefficient for this chain.
13.8. Generate a sequence of 500 normal random number on a computer.
Determine the mean, standard deviation, correlogram upto 30 lags
and the corresponding spectral density function'. V~rify whether
the sequence represents a truly independent process.

You might also like