Assignment 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

David Acharya

Assignment 2

Problem 1
Use the multiplicative congruential method to generate a sequence of four three-digit random
integers and corresponding random numbers. Let X0 = 117, a = 43, and m = 1000

Given,
X0 = 117
a = 43
m= 1000

X1 = 43 x 117 mod 1000 31


X2= 43 x 31 mod 1000 333
X3 = 43 x 333 mod 1000 319
X4= 43 x 319 mod 1000 717
X5 = 43 x 717 mod 1000 831

Problem 2
The sequence of numbers 0.54, 0.73, 0.98, 0.11 and 0.68 has been generated. Use the
Kolmogorov-Smirnov test with α = 0.05 to learn whether the hypothesis that the numbers are
uniformly distributed on the interval [0, 1] can be rejected.

H0 = The observations are from Uniform Distribution (0,1)


H1 = The observations not from Uniform Distribution (0,1)
N = The number of numbers in the sequence given.

R(i) i /N i / N-R(i) R(i)-(i-1)/N

0.11 0.2 0.09 0.11

0.54 0.4 - 0.34

0.68 0.6 - 0.28

0.73 0.8 0.07 0.13

0.98 1.0 0.02 0.18


D+ = Max{ i/N- R(i)} = 0.09
D- = Max{ R(i)-(i-1)/N} = 0.34
D = Max {D+, D- } = 0.34 < 0.565
which is less than given D0.05 = 0.565
Hence H0 is not rejected.
David Acharya

Problem 3
Figure out whether these linear congruential generators can achieve a maximum period; also,
state restrictions on X0 to obtain this period.

a. The mixed congruential method with


a = 2, 814, 749, 767, 109
c = 59, 482, 661, 568, 307
m = 248

The mixed congruential method


(a = 749 , c = 661) and ( a = 109 , c= 307) can achieve the maximum period because in both the
cases c is relatively prime to m and m (a-1) is divisible by 4. That means (a-1) / 4 is an integer.
There is no restrictions on X0 to obtain this period.

b. The multiplicative congruential method with


a = 69, 069
c=0
m = 232

The maximum period can be achieved (a-5) is divisible by 8.


That is, (69069-5) / 8 is an integer.
In this case maximum period can be achieved because X0 must be an odd integer

c. The mixed congruential method with


a = 4951
c = 247
m = 256
The maximum period cannot be achieved because m= 256 = 28 and a= 4951 which is relatively
prime to m and a-1 is not divisible by 4, (4951-1) /4 is not an integer.

d. The multiplicative congruential method with


a = 6507
c=0
m = 1024
The maximum period can be achieved because (a-3) is divisible by 8.
That is, m =1024 = 210.
That is, (a-3) /8 = (6507-3) / 8 is an integer
David Acharya

Problem 4
Consider the multiplicative congruential generator under the following circumstances:
(a) X0 = 7, a = 11, m = 16

The multiplicative congruential generator,


Xn = aXn-1 mod m, n = 1,2,…..
Given X0 = 7
X1 = 11 x 7 mod 16 = 77 mod 16 = 13
X2 = 11 x 13 mod 16 = 143 mod 16 = 15
X3 = 11 x 15 mod 16 = 165 mod 16 = 5
X4 = 11 x 5 mod 16 = 55 mod 16 = 7
The cycle repeats and the length of the cycle is 4
The maximum period occurs when X0 is odd and a has the form 3+8k where k = 1, 2, 3,…..
In this case, the maximum period 4 occurs when X0 is odd and a = 3+8k where k =1
So, the maximum period 16 is not achieved

(b) X0 = 8, a = 11, m = 16
The multiplicative congruential generator,
Xn = aXn-1 mod m, n = 1,2,…..
Given X0 = 8
X1 = 11 x 8 mod 16 = 88 mod 16 = 8
The cycle repeats and the length of the cycle is 1
The maximum period 16 is not achieve because X0 is even

(c) X0 = 7, a = 7, m = 16
The multiplicative congruential generator,
Xn = aXn-1 mod m, n = 1,2,…..
Given X0 = 7
X1 = 7 x 7 mod 16 = 49 mod 16 = 1
X2 = 1x7 mod 16 = 7 mod 16 = 7
The cycle repeats and the length of the cycle is 2
The maximum period 16 is not achieve because X0 do not have the form of 3 + 8k.

(d) X0 = 8, a = 7, m = 16
The multiplicative congruential generator,
Xn = aXn-1 mod m, n = 1,2,…..
Given X0 = 8
X1 = 8 x 7 mod 16 = 56 mod 16 = 8
The cycle repeats and the length of the cycle is 1
The maximum period 16 is not achieve because X0 is even.
David Acharya

Problem 5

CHI-SQUARE TEST
Value Df Asymptotic Significance (2-
Sided)
Pearson Chi- 306.00 289 0.235
square
Likelihood 104.053 289 1.000
ratio
Linear -by- 1.541 1 .215
Liner
Association
N of valid 18
cases

324 cells have expected count less than 5 (100%)


The minimum expected count is 6

Null Hypothesis: No association between 2 variables


Alternative Hypothesis: Association exists between 2 variables
p value is not < 0.05, fail to reject null hypothesis

You might also like