Professional Documents
Culture Documents
Solution:
1) Chi-squared test:
a) generate the sample of random numbers: apply the LCG equation 50 times to find the following random
numbers shown in this table (numbers are stored column by column so U1 = 0.06, U2 = 0.046, U3 = 0.08,
and so on):
0.06
0.046
0.808
0.762
0.98
0.686
0.688
0.722
0.3
0.126
0.168
0.882
0.02
0.366
0.248
0.242
0.14
0.406
0.928
0.802
0.66
0.246
0.208
0.562
0.58
0.886
0.088
0.522
0.9
0.326
0.568
0.682
0.62
0.566
0.648
0.042
0.74
0.606
0.328
0.602
0.26
0.446
0.608
0.362
0.18
0.086
0.488
0.322
0.5
0.526
b) divide the interval [0,1) into 5 intervals and count the frequencies:
j
1
2
3
4
5
interval
[0, 0.2)
[0.2, 0.4)
[0.4, 0.6)
[0.6, 0.8)
[0.8, 1)
frequency
10
11
10
12
7
5 5
50
=
fj
50 j =1
5
(
= 0.1((10 10 )
= 0.1 ( f 1 10 ) + ( f 2 10 ) + ( f 3 10 ) + ( f 4 10 ) + ( f 5 10 )
2
= 0.1(0 + 1 + 0 + 4 + 9)
= 1.4
2) Serial test:
a) Generate the sample of random numbers: apply the LCG equation 60 times to find the following random
numbers shown in this table (numbers are stored column by column so U1 = 0.06, U2 = 0.046, U3 = 0.08,
and so on):
0.06
0.046
0.808
0.762
0.98
0.686
0.688
0.722
0.3
0.126
0.168
0.882
0.02
0.366
0.248
0.242
0.14
0.406
0.928
0.802
0.66
0.246
0.208
0.562
0.58
0.886
0.088
0.522
0.9
0.326
0.568
0.682
0.62
0.566
0.648
0.042
0.74
0.606
0.328
0.602
0.26
0.446
0.608
0.362
0.18
0.086
0.488
0.322
0.5
0.526
0.968
0.482
0.22
0.766
0.048
0.842
0.34
0.806
0.728
0.402
b) Divide the sample into two-dimensional vectors where we will have 30 vectors as follows:
U1
[0.06, 0.046]
U11
[0.66, 0.246]
U21
[0.26, 0.446]
U2
[0.808, 0.762]
U12
[0.208, 0.562]
U22
[0.608, 0.362]
U3
[0.98, 0.686]
U13
[0.58, 0.886]
U23
[0.18, 0.086]
U4
[0.688, 0.722]
U14
[0.088, 0.522]
U24
[0.488, 0.322]
U5
[0.3, 0.126]
U15
[0.9, 0.326]
U25
[0.5, 0.526]
U6
[0.168, 0.882]
U16
[0.568, 0.682]
U26
[0.968, 0.482]
U7
[0.02, 0.366]
U17
[0.62, 0.566]
U27
[0.22, 0.766]
U8
[0.248, 0.242]
U18
[0.648, 0.042]
U28
[0.048, 0.842]
U9
[0.14, 0.406]
U19
[0.74, 0.606]
U29
[0.34, 0.806]
U10
[0.928, 0.802]
U20
[0.328, 0.602]
U30
[0.728, 0.402]
kd
=
n
2
L f j1 j2L jd d
k
j1 =1 j2 =1
jd =1
k
22 2 2
30
f j1 j2 2
30 j1 =1 j2 =1
2
4 2 2
2
f j1 j2 7.5
30 j1 =1 j2 =1
Where:
j1 are the intervals on the first dimension.
j2 are the intervals on the second dimension.
j1
1
2
Interval on First
dimension
[0, 0.5)
[0.5, 1)
j2
1
2
Interval on Second
dimension
[0, 0.5)
[0.5, 1)
d) Compute vectors frequencies: Lets work some examples before stating the final frequencies.
U1 = [0.06, 0.046]
0.06 in the first interval [0, 0.5) of j1 j1 = 1
0.046 in the first interval [0, 0.5) of j2 j2 = 1
So it is counted for f 1,1
U2 = [0.808, 0.762]
0.808 in the second interval [0.5, 1) of j1 j1 = 2
0.762 in the second interval [0.5, 1) of j2 j2 = 2
So it is counted for f 2 , 2
U6 = [0.168, 0.882]
0.168 in the first interval [0, 0.5) of j1 j1 = 1
0.882 in the second interval [0.5, 1) of j2 j2 = 2
So it is counted for f 1, 2
Final frequencies:
interval
f 1,1
frequency
8
f 1, 2
f 2,1
f 2, 2
d) Compute 2
4 2 2
=
f j j 7.5
30 j1 =1 j2 =1 1 2
2
((
) (
4 2
2
f j11 7.5 + f j1 2 7.5
30 j1 =1
))
2
(
(
4
( f11 7.5)2 + ( f12 7.5)2 + ( f 21 7.5)2 + ( f 22 7.5)2
30
4
(8 7.5)2 + (7 7.5)2 + (6 7.5)2 + (9 7.5)2
=
30
= 0.67
3) Runs Test
a) Generate the sample of random numbers: apply the LCG equation 50 times to find the following random
numbers shown in this table (numbers are stored column by column so U1 = 0.06, U2 = 0.046, U3 = 0.08,
and so on):
0.06
0.046
0.808
0.762
0.98
0.686
0.688
0.722
0.3
0.126
0.168
0.882
0.02
0.366
0.248
0.242
0.14
0.406
0.928
0.802
0.66
0.246
0.208
0.562
0.58
0.886
0.088
0.522
0.9
0.326
0.568
0.682
0.62
0.566
0.648
0.042
0.74
0.606
0.328
0.602
0.26
0.446
0.608
0.362
0.18
0.086
0.488
0.322
0.5
0.526
Length
1
2
2
3
1
3
2
1
1
1
2
1
1
1
4
3
3
1
2
2
1
1
1
3
1
1
2
4
1
2
2
2
1
1
Frequency
17
10
5
2
0
d) Compute R as follows:
R=
1
N
a (r
i =1 j =1
ij
nbi )(r j nb j )
From your textbook page 408 you find the values of constants a and b as follows:
1
N
a (r nb )(r
6
i =1 j =1
ij
nb j )
1 6 ai1 (ri nbi )(r1 nb1 ) + ai 2 (ri nbi )(r2 nb2 ) + ai 3 (ri nbi )(r3 nb3 ) + ai 4 (ri nbi )(r4 nb4 )
a11 (r1 nb1 )(r1 nb1 ) + a12 (r1 nb1 )(r2 nb2 ) + a13 (r1 nb1 )(r3 nb3 ) + a14 (r1 nb1 )(r4 nb4 )
+ a15 (r1 nb1 )(r5 nb5 ) + a16 (r1 nb1 )(r6 nb6 )
+ a (r nb )(r nb ) + a (r nb )(r nb ) + a (r nb )(r nb ) + a (r nb )(r nb )
2
1
1
22 2
2
2
2
23 2
2
3
3
24 2
2
4
4
21 2
+ a25 (r2 nb2 )(r5 nb5 ) + a26 (r2 nb2 )(r6 nb6 )
+ a31 (r3 nb3 )(r1 nb1 ) + a32 (r3 nb3 )(r2 nb2 ) + a33 (r3 nb3 )(r3 nb3 ) + a34 (r3 nb3 )(r4 nb4 )
1 + a35 (r3 nb3 )(r5 nb5 ) + a36 (r3 nb3 )(r6 nb6 )
=
34 + a41 (r4 nb4 )(r1 nb1 ) + a42 (r4 nb4 )(r2 nb2 ) + a43 (r4 nb4 )(r3 nb3 ) + a44 (r4 nb4 )(r4 nb4 )
+ a (r nb )(r nb ) + a (r nb )(r nb )
4
5
5
46 4
4
6
6
45 4
+ a51 (r5 nb5 )(r1 nb1 ) + a52 (r5 nb5 )(r2 nb2 ) + a53 (r5 nb5 )(r3 nb3 ) + a54 (r5 nb5 )(r4 nb4 )
+ a55 (r5 nb5 )(r5 nb5 ) + a56 (r5 nb5 )(r6 nb6 )
+ a61 (r6 nb6 )(r1 nb1 ) + a62 (r6 nb6 )(r2 nb2 ) + a63 (r6 nb6 )(r3 nb3 ) + a64 (r6 nb6 )(r4 nb4 )
+ a65 (r6 nb6 )(r5 nb5 ) + a66 (r6 nb6 )(r6 nb6 )
11
1
5
1
1
1
1
19
1
29
1
1
) + 22615(17 50 * )(0 50 *
) + 27892(17 50 * )(0 50 *
)
+ 18091(17 50 * )(2 50 *
6
720
6
5040
6
840
1
5
11
5
5
5
840
24
5040
24
720
24
1
11
29
11
19
11
)
)(0 50 *
) + 83685(5 50 *
)(0 50 *
) + 67852(5 50 *
)(r4 50 *
+ 54281(5 50 *
1
840
120
5040
120
720
120
11
19
5
19
1
19
34
)
)(5 50 *
)(10 50 * ) + 54281(2 50 *
)(17 50 * ) + 36187(2 50 *
+ 18091(2 50 *
120
720
24
720
6
720
19
1
19
29
19
19
+ 72414(2 50 * 720 )(2 50 * 720 ) + 90470(2 50 * 720 )(0 50 * 5040 ) + 111580(2 50 * 720 )(0 50 * 840 )
120
5040
24
5040
6
5040
5040
5040
720
5040
840
5040
11
1
5
1
1
1
+ 27892(0 50 *
)
)(5 50 *
)(10 50 * ) + 83685(0 50 *
)(17 50 * ) + 55789(0 50 *
120
840
24
840
6
840
1
1
29
1
19
1
)
)(0 50 *
) + 172860(0 50 *
)(0 50 *
) + 139476(0 50 *
)(2 50 *
+ 111580(0 50 *
840
840
5040
840
720
840
= 13317.9
4) Correlation Test
a) Generate the sample of random numbers: apply the LCG equation 50 times to find the following random
numbers shown in this table (numbers are stored column by column so U1 = 0.06, U2 = 0.046, U3 = 0.08,
and so on):
0.06
0.046
0.808
0.762
0.98
0.686
0.688
0.722
0.3
0.126
0.168
0.882
0.02
0.366
0.248
0.242
0.14
0.406
0.928
0.802
0.66
0.246
0.208
0.562
0.58
0.886
0.088
0.522
0.9
0.326
0.568
0.682
0.62
0.566
0.648
0.042
0.74
0.606
0.328
0.602
0.26
0.446
0.608
0.362
0.18
0.086
0.488
0.322
0.5
0.526
b) Lets work with lag 5 (i.e. j = 5) and see whether this LCG pass the correlation test for lag 5.
First we will compute the following:
Aj =
A5 =
[ ]
Var j
Var [ 5 ]
But:
j =
12 h
U 1+ kjU 1+( k +1) j 3
h + 1 k =0
5 =
12 h
U 1+5kU 1+5( k +1) 3
h + 1 k =0
And
h = (n 1) / j 1
h = (50 1) / 5 1
h = 9.8 1
h = 9 1 = 8
Then
5 =
12 8
U 1+5kU 1+5( k +1) 3
9 k =0
12
(U 1U 6 + U 6U 11 + U 11U 16 + U 16U 21 + U 21U 26 + U 26U 31 + U 31U 36 + U 36U 41 + U 41U 46 ) 3
9
12 0.06 * 0.686 + 0.686 * 0.168 + 0.168 * 0.242 + 0.242 * 0.66 + 0.66 * 0.886 + 0.866 * 0.568 +
3
=
9 0.568 * 0.042 + 0.042 * 0.26 + 0.26 * 0.86
12
(1.502) 3
9
= 0.997
=
Then
Var [ 5 ] =
13h + 7 13 * 8 + 7
=
= 1.37
81
(h + 1) 2
Finally we get:
A5 =
Var [ 5 ]
0.997
1.37
= 0.852
c) Compare A j with the critical value z1 / 2 = z 0.975 = 1.96 which is found in Table T.1 at page 716.
0.852 < 1.96 the LCG has passed the correlation test for lag 5 and so it is independent at this lag.