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

Assgn

1. The question presents a combined linear congruential generator using 3 individual generators with specific parameters to generate random numbers for 16-bit computers. 2. It provides the initial seed values and generates the first 4 random numbers as 11613, 14785, 19973, and 25717 by applying the combined generator formula at each step. 3. The combined generator formula calculates the next value as the sum of the next values from each individual generator, taken modulo the period of the first generator. This exploits the individual generators to produce a longer combined period of around 8 billion.

Uploaded by

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

Assgn

1. The question presents a combined linear congruential generator using 3 individual generators with specific parameters to generate random numbers for 16-bit computers. 2. It provides the initial seed values and generates the first 4 random numbers as 11613, 14785, 19973, and 25717 by applying the combined generator formula at each step. 3. The combined generator formula calculates the next value as the sum of the next values from each individual generator, taken modulo the period of the first generator. This exploits the individual generators to produce a longer combined period of around 8 billion.

Uploaded by

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

1.

Manual Simulation
A) simulate 10 individuals Probability of time between Calls

Time between Probability RD Assignment


calls (Minute) Between Calls Cumulative
Probability
15 0.15 0.15 0-15
20 0.20 0.35 16-35
25 0.45 0.80 36-80
30 0.15 0.95 81-95
35 0.05 1.00 96-00

Probability of Service Time


Service Time Probability of RD Assignment
(Minutes) Service Time Cumulative
Probability
5 0.15 0.15 1-15
15 0.35 0.50 16-50
25 0.40 0.90 51-90
35 0.06 0.96 91-96
45 0.04 1.00 97-00

First, simulate for one taxi for 10 days. Then, simulate for two taxis for 10 days.

Comparison
Taxi Company would have to decide which is more important paying for about 43 hours of
production timein a Ten day period with no customers having to wait, or paying for around 4
hours of Production time ina Ten day period, but having a probability of waiting equal to 0.59
with an average waiting time for
those who wait of around 20 minutes.

Day Call RD for


Time RD for Time Time Time
Time Call Service
between Service Service Customer Servic
between Time Time
Calls Time Begins Waits Ends
Calls
1 15 - 0 01 5 0 0 5
2 01 20 20 50 25 20 0 53
3 15 15 35 60 25 53 20 78
4 65 25 60 53 25 78 20 103
1 5 73 25 85 93 35 103 20 137
6 48 25 110 20 15 138 30 153

88
154 50 126 50 920 50 1056

8
B) Compare the two systems with respect to the waiting times
Total idle time = 530 minutes = 8.816 hours
Average idle time per call = 2.7 minutes
Proportion of idle time = 0.11
Total time customers wait = 4266 minutes
Average waiting time per customer = 11.9 minutes
Number of customers that wait = 122 (of 226 customers)
Probability that a customer has to wait = .61
Average waiting time of customers that wait = 20.2 minutes
3. Statistical Models in Simulation
(A) Customers at a restaurant arrive in groups (one to eight persons). The number of
persons(per group) for 300 customers and the relative frequencies are given below.
Draw the empirical cumulative distribution function (cdf)
Arrival per party 1 2 3 4 5 6 7 8
Frequency 30 110 45 71 12 13 7 12

(b) A hurricane is to hit in country, and expected to follow Poisson distribution with a mean of
08 per year.
i. computer the probability of exactly one hurricane in a year will be.

Solution:- mean = 0.8 x = 1


P(x) = (Exp[-mean] * mean ^x )/ x!
= (Exp[-0.8]*0.8^1)/1!
= Exp[-0.8]*0.8
=0.36
ii. Compute the probability of more than two hurricane in one year will be

solution P(x, x>2) = 1 - P(0) - P(1) - P(2)


= 1 - (Exp[-0.8]*0.8^0)/0! - (Exp[-0.8]*0.8^1)/1!- (Exp[-0.8]*0.8^2)/2!
= 1 - Exp[-0.8]*1 - Exp[-0.8]*0.8 - (Exp[-0.8]*0.8^2)/2
= 1 - 0.45 - 0.36 - 0.147
= 1 – 0.957
= 0.043

(c) The lifetime, in years, of a satellite place in orbit is given be exponential distribution

withlambda = 0.4
i. what is the probability of the satellite lasting at least five years?

Solution: P(x, x >= 5) = F(infinity) – F(5)

Exponential distribution f(x) = lambda*Exp[-lambda*x] for x >= 0

F(x) = 1- Exp[-lambda*x]

F(infinity) = 1 and F(5) => F(5) –F(0) => F(0)= 1- Exp[-lambda*0]

F(0) = 1-1 = 0

So:- P(x, x>=5) = 1 – F(5)

1 – (1- Exp[-lambda*5] ) = 1 – (1- Exp[-0.4*5] )

1 – (1- Exp[-2]) = 1-(1-0.135)

= 0.135

ii. what is the probability that the satellite dies between three and six years?
Solution:- P(x, 3<x<6) = F(6) – F(3)
= (1- Exp[-lambda*6] ) - ( 1- Exp[-lambda*3])
= ( 1- Exp[-0.4*6]) - (1- Exp[-0.4*3])
= ( 1- Exp[-2.4] ) - (1- Exp[-1.2])
= (1 - 0.09) - ( 1 - 0.301)
= 0.91 – 0.699
= 0.211

(d) The time to failure of a battery is Weibull distributed with parameters


(beta = 1/ 4 alpha = 1/2 v = 0)

i. Find the probability that the battery will fail within 1.5 years.

Solution:-weibull distribution

f(x) = beta/alpha*(x – v)^(beta -1) * Exp[-((x-v)/alpha)^beta] for x > v

1 else

F(x) = 1 – Exp[ -(x/alpha)^beta]

= 1 – Exp[ -(1.5/0.5)^0.25 ]

= 1 – 0.268

= 0.732

ii. Find the probability that battery will last for longer than its mean life.

Solution:- mean of weibull distribution is


E(x) = v + alpha r( 1/beta +1)
= 0 + 0.5 r(1/0.25 +1)
= 0.5 ((5-1)!)
= 0.5 * 24
= 12

P(x,x>12) = 1 –F(12)

F(60) = 1 – Exp[ -(x/alpha)^beta]


= 1 – Exp[-(12/0.5)^0.25]
= 1 – 0.109

P(x,x>12) = 0.891
iii. Find the probability that battery will last between 1.5 and 2.5 years.

Solution:- battery last between 1.5 to 2.5


P(1.5 < x <2.5) = F(2.5) – F(1.5)

F(2.5) = 1 – Exp[ -(2.5/0.5)^0.25 = 1 – 0.224


= 0.775
F(1.5) = 1 – Exp[ -(1.5/0.5)^0.25 = 1 – 0.268
= 0.731
P(1.5 < x <2.5) = 0.775 - 0.731 = 0.044

Question 4 :- Linear Congruential Generator

For 16-bit computers it was recommended to combine three multiplicative generators

With m1 = 32363, alpha1 = 157,

m2 = 31727, alpha2= 146,

m3= 31657, and alpha3= 142.

The period of this generator is approximately 8* 10^12

(a) Generate 10 random numbers with the combined generator, using the initial seeds
X(i,0) = 100, 300, 500, for the individual generators i = 1, 2, 3.

Solution:- initial seeds X(1,0) = 100


X(2,0) = 300
X(2,0) = 500
C=0

Combined generator => X(j+1) = ( X(1,j+1) – X(2,j+1) + X(3,j+1) ) mode ( m1 -1)

=> X(I,j+1) = [ alpha(i) * X(I,j) ] mode m(i)

X(1,1) = [ 157 * 100 ] mode 32363


X(2,1) = [ 146 * 300 ] mode 31727
X(3,1) = [ 142 * 500 ] mode 31657

 X(1) = [ X(1,1) - X(2,1) + X(3,1) ] mode (m1 – 1)


= ( [ 157 * 100 ] mod 32363 - [ 146 * 300 ] mod 31727 + [ 142 * 500 ] mod 31657 ) mod
(32363 -1 )

= ( 15700 mod 32363 – 43500 mod 31727 + 71000 mod 31657 ) mod 32362
= ( 15700 - 11773 + 7686 ) mod 32362
= 11613 mod 32362
X(1) = 11613

X(1,1) = 15700 X(2,1) = 11773 X(3,1) = 7686

 X(2) = [ X(1,2) - X(2,2) + X(3,2) ] mode (m1 – 1)


= ( [ 157 * 15700 ] mod 32363 - [ 146 * 11773 ] mod 31727 + [ 142 * 7686 ] mod 31657 )
mod (32362 )

= ( 5312 - 5600 + 15074 ) mod 32362

X(2) = 14785
X(1,2) = 5312 X(2,2) = 5600 X(3,2) = 15074

 X(3) = [ X(1,3) - X(2,3) + X(3,3) ] mode (m1 – 1)


= ( [ 157 * 5312 ] mod 32363 - [ 146 * 5600 ] mod 31727 + [ 142 * 15074 ] mod 31657 )
mod (32362 )

= ( 24,909 - 24,425 + 19489 ) mod 32362

X(3) = 19,973
X(1,3) = 24,909 X(2,3) = 24,425 X(3,3) = 19489
 X(4) = [ X(1,4) - X(2,4) + X(3,4) ] mode (m1 – 1)
= ( [ 157 * 24,909 ] mod 32363 - [ 146 * 24,425 ] mod 31727 + [ 142 * 19489 ] mod 31657 )
mod (32362 )

= ( 27153 - 12626 + 13279 ) mod 32362

X(4) = 27,806
X(1,4) = 27153 X(2,4) = 12626 X(3,4) = 12626

 X(5) = [ X(1,5) - X(2,5) + X(3,5) ] mode (m1 – 1)


= ( [ 157 * 27153 ] mod 32363 - [ 146 * 12626 ] mod 31727 + [ 142 * 12626 ] mod 31657 )
mod (32362 )

= ( 23468 - 3230 + 25541 ) mod 32362


X(5) = 13417
X(1,5) = 23468 X(2,5) = 3230 X(3,5) = 25541

 X(6) = [ X(1,6) - X(2,6) + X(3,6) ] mode (m1 – 1)


= ( [ 157 * 23468 ] mod 32363 - [ 146 * 3230 ] mod 31727 + [ 142 * 25541 ] mod 31657 )
mod (32362 )

= ( 27457 - 13402 + 17924 ) mod 32362

X(6) = 3052
X(1,6) = 27457 X(2,6) = 13402 X(3,6) = 17924

 X(7) = [ X(1,7) - X(2,7) + X(3,7) ] mode (m1 – 1)


= ( [ 157 * 27457 ] mod 32363 - [ 146 * 13402 ] mod 31727 + [ 142 * 17924 ] mod 31657 )
mod (32362 )

= ( 6470 - 21345 + 16616 ) mod 32362

X(7) = 1741
X(1,7) = 6470 X(2,6) = 21345 X(3,6) = 16616

 X(8) = [ X(1,8) - X(2,8) + X(3,8) ] mode (m1 – 1)


= ( [ 157 * 6470 ] mod 32363 - [ 146 * 21345 ] mod 31727 + [ 142 * 16616 ] mod 31657 )
mod (32362 )

= ( 12537 - 598 + 16854 ) mod 32362

X(8) = 28793
X(1,8) = 12537 X(2,8) = 598 X(3,8) = 16854
 X(9) = [ X(1,9) - X(2,9) + X(3,9) ] mode (m1 – 1)
= ( [ 157 * 12537 ] mod 32363 - [ 146 * 598 ] mod 31727 + [ 142 * 16854 ] mod 31657 )
mod (32362 )

= ( 26529 - 23854 + 18993 ) mod 32362

X(9) = 21668
X(1,9) = 26529 X(2,9) = 23854 X(3,9) = 18993

 X(10) = [ X(1,10) - X(2,10) + X(3,10) ] mode (m1 – 1)


= ( [ 157 * 26529 ] mod 32363 - [ 146 * 23854 ] mod 31727 + [ 142 * 18993 ] mod 31657 )
mod (32362 )

= ( 22589 - 24441 + 6161 ) mod 32362

X(10) = 4309
X(1,10) = 22589 X(2,10) = 24441 X(3,10) = 6161

(b) Apply the uniformity and independence tests to the generator and comment on the results.

Solution:- the random numbers that are generated are


R = [ 11,613, 14,785, 19,973, 27,806, 13,417, 3052, 1741, 28,793, 21,668, 4309]

Order it from smallest to largest

 1741, 3052, 4309, 11613, 13417, 14785, 19973, 21668, 27806 ,28793

Make range between 0 and 1 dividing it by 32362

 0.05, 0.09, 0.133, 0.358, 0.414,0.456, 0.617, 0.669, 0.859, 0.889

Uniformity (The Kolmogorov-Smirnov) test

n = 10 and alpha = 0.05


D+ = Max [i/n - R(i)] for 1 < I < n
D- = Max [R(i) - (I – 1)/n ] for 1 < I < n
D = Max (D- , D+)
If D < D(alpha) => uniformity hypothesis is not rejected

Then find D+ and D- for all of the

D+ => [ 0.05, 0.11, 0.167, 0.042, 0.086, 0.144, 0.083, 0.131, 0.041, 0.111 ]
D- => [ 0.05, -0.01, -0.067, 0.058, 0.014, -0.044, 0.017, -0.031, 0.059, -0.011]

MAX of D+ = 0.167 and MAX of D- = 0.059


D = Max (0.167 , 0.059) => 0.167

D(alpha) = D(0.005) = for N=10 is 0.410

 0.167 < 0.410 uniformity hypothesis is not rejected

Independence test

5. Characteristics of Random Numbers

at R(10), the value of D+ is given by 10/20 − R(10) = 0.5 − 0.474 =0.26 and that
of D− is given by R(10) − 9/10 = 0.474 − 0.45= 0.24

The critical value of D, obtained from Table A.8 in the Appendix


for α = 0.05 and N = 20, is 0.356
.
Since the computed value, 0.26 , is less than the tabulated critical value 0.356, the hypothesis
that
the distribution of the generated numbers is the uniform distribution is not rejected.
the maximum deviation over all x, it can
be seen from Figure 2 that the maximum deviation will always occur at one of the jump points
R(1), R(2), . . . , R(N); thus, the deviation at other values of x need not be considered

6. Characteristics of Random Numbers


In some applications, it is useful to be able to quickly skip ahead in a pseudo-random
number sequence without actually generating all of the intermediate values.
(a) For a linear congruential generator with c = 0, show that Xi+n = αnXi mod m.
(b) Show that (αnXi) mod m = (αn mod m)Xi mod m
(c) Use this result to compute X6 with a congruential generator with m = 100; α = 19,
and c = 0. Start with X0 = 63 and check your answer by computing X6 in the usual way.

Answer
Two results that are useful to solve this problem are

and that if g = h mod m, then we can write g = h-km for some integer k >=0. The last result is
true because, by definition, g is the remainder after subtracting the largest integer multiple of m
thatis <= h.
7. Random -Variate Generator
Develop a random-variate generator for a random variable X with the pdf

F(x) = - 0.25 * Exp [-4x] - ∞ < x <= 0

0.25 * Exp[4x] 0<x<∞

R = F(x)

X = inverse function of F(R)


X = ln(-4R)/-4 for -1/4 > R > - ∞
X = ln(4R)/-4 for 1/4 < R < -∞

8. INPUT MODELING THE TIME REQUIRED FOR THE TRANSMISSION OF A MESSAGE (IN MINUTES) IS
SAMPLED ELECTRONICALLY AT A COMMUNICATIONS CENTER. THE LAST 50 VALUES IN THE SAMPLE ARE AS
FOLLOWS.
7.936 4.612 2.407 4.278 5.132
4.599 5.224 2.003 1.857 2.696
5.259 7.563 3.937 6.908 5.002
6.212 2.759 7.172 6.513 3.326
8.761 4.502 6.188 2.566 5.515
3.785 3.742 4.682 4.346 5.359
3.535 5.061 4.629 5.298 6.492
3.502 4.266 3.129 1.298 3.454
5.289 6.805 3.827 3.912 2.969
4.646 5.963 3.829 4.402 4.924
The data were collected over the interval from 0 to T = 100 minutes. It can be shown that,
if the underlying distribution of Transmission times {T1, T2, . . . } is exponential, the arrival times are
uniformly distributed on the interval [0, T]. The arrival times T1, T1 + T2, T1 + T2 + T3, . . . ,
T1 +· · ·+T50 are obtained by adding Transmission times. The Transmission times are then normalized to a
[0, 1] interval so that the Kolmogorov–Smirnov test can be applied. On a [0, 1] interval, the points
will be [T1/T, (T1 + T2)/T, . . . , (T1 +· · ·+T50)/T]. The resulting 50 data points are as follows

0.07936 0.12548 0.10343 0.12214 0.13068


0.12535 0.1316 0.09939 0.09793 0.10632
0.13195 0.15499 0.11873 0.14844 0.12938
0.14148 0.10695 0.15108 0.14449 0.11262
0.16697 0.12438 0.14124 0.10502 0.13451
0.11721 0.11678 0.12618 0.12282 0.13295
0.11471 0.12997 0.12565 0.13234 0.14428
0.11438 0.12202 0.11065 0.09234 0.1139
0.13225 0.14741 0.11763 0.11848 0.10905
0.12582 0.13899 0.11765 0.12338 0.1286

(a) How are the transmission times distributed?

Solution: -

The sample data represent by normal distribution

With a mean = 99.22

Variance = 103.41

(b) Develop and test an appropriate model

Solution:-

Number of cells (k) (X0)^2 X.05,k-3 decision


10 3.2 14.1 don’t reject
8 1.2 11.1 don’t reject
5 1.0 5.99 don’t reject
9. THE TIME (IN MINUTES) BETWEEN REQUESTS TO A WEB SERVER WAS RECORDED WITH
THE FOLLOWING LAST 50 REQUESTS
0.661 4.91 8.989 12.801 20.249
5.124 15.033 58.091 1.543 3.624
13.509 5.745 0.651 0.965 62.146
15.512 2.758 17.602 6.675 11.209
2.731 6.892 16.713 5.692 6.636
2.42 2.984 10.613 3.827 10.244
6.255 27.969 12.107 4.636 7.093
6.892 13.243 12.711 3.411 7.897
12.413 2.169 0.921 1.9 0.315
4.37 0.377 9.063 1.875 0.79

The data were collected over the interval from 0 to T = 100 minutes. It can be shown that,
if the underlying distribution of Transmission times {T1, T2, . . . } is exponential, the arrival times are
uniformly distributed on the interval [0, T]. The arrival times T1, T1 + T2, T1 + T2 + T3, . . . ,
T1 +· · ·+T50 are obtained by adding Transmission times. The Transmission times are then normalized to a
[0, 1] interval so that the Kolmogorov–Smirnov test can be applied. On a [0, 1] interval, the points
will be [T1/T, (T1 + T2)/T, . . . , (T1 +· · ·+T50)/T]. The resulting 50 data points are as follows

0.0066
1 0.05571 0.0965 0.13462 0.2091
0.0578
5 0.15694 0.58752 0.02204 0.04285
0.1417 0.06406 0.01312 0.01626 0.62807
0.1617
3 0.03419 0.18263 0.07336 0.1187
0.0339
2 0.07553 0.17374 0.06353 0.07297
0.0308
1 0.03645 0.11274 0.04488 0.10905
0.0691
6 0.2863 0.12768 0.05297 0.07754
0.0755
3 0.13904 0.13372 0.04072 0.08558
0.1307
4 0.0283 0.01582 0.02561 0.00976
0.0503
1 0.01038 0.09724 0.02536 0.01451

You might also like