Академический Документы
Профессиональный Документы
Культура Документы
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.
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;
Exercise 6: Give algorithms for generating from the density function given
in equation (2) using:
1. Inverse-transform method;
2. Acceptance-rejection method.
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