Вы находитесь на странице: 1из 5

Solutions to Exercise 3

Random Number and Random Variable


Exercise 1: What are the characteristics of a good random number generator?
Solution Exercise 1: Good algebraic RN generators should possess several
properties:
1. Numbers produced should appear to be distributed uniformly on [0,1] and
should not exhibit any correlation with each other, ie., future RNs should
not be influenced by past values.
2. From a practical stand-point the RN generators should be fast and avoid
the need for a lot of storage.
3. They should possess the ability to reproduce a given stream of RNs
exactly. This is desirable for at least two reasons:
a. It would make debugging or verification of the computer program
easier.
b.

It allows one to compare alternative system designs under the


same experimental conditions. The experimental conditions are
the generated random variables that are used to drive the simulation
model.

Exercise 2: Given a random number stream U1, U2, . . . Un, describe two tests that can
be used to check the randomness (or independence) and uniformity of the generator.
Solution Exercise 2: Two tests are the moments test and the chi-squared test. In the
moments test the first, second and third moments are calculated as below.

The first, second and third moments should be equal to , 1/3, for the U(0,1) when
n is very large. The chi-squared test is used to test the hypothesis that a sample of
random variables X1,X2, . . . ,Xn following a particular standard distribution. If U(0,1)
is divided into k intervals then the chi-squared test statistic is:

Exercise 3: Give algorithms for generating from the probability density functions
given in equations (1) using (i) the inverse method and (ii) the acceptance-rejection
method.

Exercise 4: The linear congruential generator (LCG) is the most widely used random
number generator in simulation packages. Demonstrate how the LCG is used.

Exercise 5: Linear congruential generators (LCG) are defined by the recursive


formula:

where m is the modulus, a is the multiplier and c is the increment.


1. What is the upper limit of the period of the above generator?
2. Why is recommended that LCG have full periods?
3. Distinguish between mixed LCG and multiplicative LCG.
Solution Exercise 5: Answers are:
1. m is the upper limit;
2.

A generator with full period will have a period equal to m. Because all
values between 0 and m1 are used the spread of values from between 0
and 1 is maximized;

3. The LCG formula is:


Zi = (aZi1 + c)(mod m)

Exercise 6: Give algorithms for generating from the density function given
in equation (2) using:
1. Inverse-transform method;
2. Acceptance-rejection method.

Solution Exercise 6: The two methods are:

The algorithm for generating RV using the Inverse method is:


1. Generate Ui;

Exercise 7: The distribution function of the exponential distribution is:

where is the mean. Show how the inverse method is used to sample from this
distribution.

Solution Exercise 7:

Exercise 8: It is required to sample from the 3-Erlang distribution with mean time
equal to 9. Given a function expon(x) which returns a sample from the exponential
distribution with mean time x. Show using pseudo computer code how a sample from
the 3-Erlang distribution can be obtained.
Solution Exercise 8: To generate a 3-Erlang RV, the algorithm is:
1. Generate Y1 = expon(3), Y2 = expon(3), Y3 = expon(3).
2. Return X = Y1 + Y2 + Y3

Вам также может понравиться