Homework 7, Chapter 7,8 Solution
Generate 1000 random numbers between 0 and 1, based on the linear
congruential techniques covered last week. Use a modulus size of at least 1000.
Find the number of up-runs and down-runs in the sequence. Using the run-test
method discussed, see if the sequence appears independent with a 5% level of
significance.
To create a generator with the maximum possible period, we can pick parameters as follows:
m is a power of 2
c is relatively prime to m
a = 1+4k, where k is an integer.
Generate a set of random numbers
You could write your
own upruns( ) function,
or find it in the solution
to the Spring '03 final.
Mean and variance in number of runs in a sequence of length 1000 is
Test statistic, Z.0:
The cumulative normal distribution is:
Find a z.a so that f(-z.a) = .025 and f(z.a)=.975. This will provide the
critical value z.a that we can compare the run statistic z.0 to.
so,
The calculated statistic is -0.701, which is in the range of -z.a - z.a, so we cannot
reject the null hypothesis. This distribution of random numbers cannot be distinguished
from a uniform distribution at the 5% level of significance.
Chapter 8, Problem 3: Develop a generator for a triangular distribution with range
(1,10) and mode x=4.
The triangle has a base from a=1 to c=10 and a height at b=4 to provide an
area, since this is a p.d.f.
The definition of F(x):
Perform the integration on each segment:
Plot the two to verify that the cumulative distribution we derived is correct:
Now, define R:
for a<X<b
implies
for b<X<c
implies
Now, test the generator by generating 10000 uniformly distributed R.V.s and convert
them to the triangular distribution
Chapter 8, Problem 17: Lead times have been found to be exponentially distributed
with mean 3.7 days. Generate 5 random lead times from this distribution.
Using
Test the generator with a large number of values.
To address the problem stated: