Simulation Homework 2 Chapter 2 Random Numbers and Random Variables
Simulation Homework 2 Chapter 2 Random Numbers and Random Variables
Simulation Homework 2 Chapter 2 Random Numbers and Random Variables
SIMULATION
HOMEWORK 2 CHAPTER 2
RANDOM NUMBERS AND RANDOM VARIABLES
1. Use the linear algorithm to generate a sequence of three two-digit random integers
and corresponding numbers. Let X0 = 27, a = 8, c = 47, and m = 100.
3. 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.
𝐷 + = 0.09 𝐷 − = 0.34
+ −)
𝐷 = max(𝐷 , 𝐷 = max(0.09,0.34) = 0.34
𝑓𝑜𝑟 ∝= 0.05 → 𝐷0.05,5 = 0.56328
𝐷0.05,5 < 𝐷 → 𝑇ℎ𝑒 𝐻0 𝑖𝑠 𝑛𝑜𝑡 𝑟𝑒𝑗𝑒𝑐𝑡𝑒𝑑, 𝑠𝑜 𝑡ℎ𝑒 𝑛𝑢𝑚𝑏𝑒𝑟𝑠 𝑎𝑟𝑒 𝑢𝑛𝑖𝑓𝑜𝑟𝑚𝑙𝑦 𝑑𝑖𝑠𝑡𝑟𝑖𝑏𝑢𝑡𝑒𝑑
John Mora Carrillo
4. Use Chi-square test, with α = 0.05, to learn whether the hypothesis that the numbers
are uniformly distributed on the interval 0,1 can be rejected.
0.43 0.09 0.52 0.98 0.78 0.44 0.21 0.12 0.64 0.76
0.38 0.67 0.97 0.46 0.07 0.18 0.49 0.47 0.22 0.47
0.69 0.99 0.77 0.76 0.65 0.14 0.25 0.37 0.99 0.20
0.74 0.03 0.71 0.28 0.65 0.50 0.54 0.13 0.87 0.50
0.97 0.17 0.32 0.91 0.28 0.39 0.56 0.73 0.93 0.24
0.99 0.71 0.99 0.64 0.50 0.66 0.01 0.24 0.81 0.94
0.73 0.15 0.45 0.10 0.18 0.82 0.96 0.43 0.57 0.94
0.27 0.34 0.65 0.79 0.03 0.49 0.69 0.85 0.37 0.50
0.60 0.93 0.48 0.42 0.04 0.46 0.04 0.91 0.97 0.26
0.81 0.62 0.79 0.88 0.46 0.74 0.06 0.11 0.92 0.87
(𝑶𝒊 − 𝑬𝒊 )𝟐
𝑵° 𝑰𝒏𝒕𝒆𝒓𝒗𝒂𝒍 𝑶𝒊 𝑬𝒊 (𝑶𝒊 − 𝑬𝒊 ) (𝑶𝒊 − 𝑬𝒊 )𝟐
𝑬𝒊
1 [0.0 - 0.1) 8 10 -2 4 0.4
2 [0.1 - 0.2) 9 10 -1 1 0.1
3 [0.2 - 0.3) 10 10 0 0 0
4 [0.3 - 0.4) 6 10 -4 16 1.6
5 [0.4 - 0.5) 13 10 3 9 0.9
6 [0.5 - 0.6) 8 10 -2 4 0.4
7 [0.6 - 0.7) 11 10 1 1 0.1
8 [0.7 - 0.8) 12 10 2 4 0.4
9 [0.8 - 0.9) 7 10 -3 9 0.9
10 [0.9 – 1.0) 16 10 6 36 3.6
100 8.4
𝜒 2 = 8.4
2
𝜒0.05,99 = 16.92
2
𝜒 2 < 𝜒0.05,99 𝑇ℎ𝑒 𝐻0 𝑖𝑠 𝑛𝑜𝑡 𝑟𝑒𝑗𝑒𝑐𝑡𝑒𝑑, 𝑠𝑜 𝑡ℎ𝑒 𝑛𝑢𝑚𝑏𝑒𝑟𝑠 𝑎𝑟𝑒 𝑢𝑛𝑖𝑓𝑜𝑟𝑚𝑙𝑦 𝑑𝑖𝑠𝑡𝑟𝑖𝑏𝑢𝑡𝑒𝑑
5. Test the following sequence of numbers 2º, 9ª, 16ª,... for independence, use
= 0.05 .
0.30 0.48 0.36 0.01 0.54 0.34 0.96 0.06 0.61 0.85
0.48 0.86 0.14 0.83 0.89 0.37 0.49 0.60 0.04 0.83
0.42 0.83 0.37 0.21 0.90 0.89 0.91 0.79 0.57 0.99
0.95 0.27 0.41 0.81 0.96 0.31 0.09 0.06 0.23 0.77
0.73 0.47 0.13 0.55 0.11 0.75 0.36 0.25 0.23 0.72
0.60 0.83 0.70 0.30 0.26 0.38 0.05 0.19 0.73 0.44
𝑖=2 𝑚=7 𝑁 = 60
𝑖 + (𝑀 + 1)𝑚 ≤ 𝑁
2 + (𝑀 + 1)7 ≤ 60
2 + (7 + 1)7 ≤ 60
58 ≤ 60
𝑀=7
John Mora Carrillo
7
1
𝜌̂25 = [∑ 0.48 ∗ 0.61 + 0.61 ∗ 0.37 + 0.37 ∗ 0.37 + 0.37 ∗ 0.99 + 0.99 ∗ 0.09 + 0.09
7+1
𝑘=0
1
𝜌̂25 = [1.6043] − 0.25
8
1
𝜌̂25 = [1.6043] − 0.25
8
𝜌̂25 = −0.049
√13𝑀 + 7
𝜎̂𝜌̂25 =
12(𝑀 + 1)
√13(7) + 7 9.899
𝜎̂𝜌̂25 = = = 0.103
12(7 + 1) 96
𝜌̂25 −0.049
𝑍= = = −0.476
𝜎̂𝜌̂25 0.103
𝑍0.025 = −1.96
𝑍 < 𝑍0.025 𝑇ℎ𝑒𝐻0 𝑖𝑠 𝑛𝑜𝑡 𝑟𝑒𝑗𝑒𝑐𝑡𝑒𝑑, 𝑠𝑜 𝑡ℎ𝑒 𝑑𝑎𝑡𝑎 𝑎𝑟𝑒 𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑖𝑒𝑛𝑡 𝑎𝑛𝑑 ℎ𝑎𝑣𝑒 𝑛𝑜 𝑐𝑜𝑟𝑟𝑒𝑙𝑎𝑡𝑖𝑜𝑛.
6. Develop a generator for a triangular distribution with range (1, 10) and mode
at x=4. Generate 10 values of the random variable.
0, 𝑥≤1
(𝑥 − 1) 2
, 1<𝑥≤4
𝐹(𝑥) = 27
(10 − 𝑥)2
1− , 4 < 𝑥 < 10
54
{1 , 𝑥 ≥ 10
0 ,𝑟 ≤ 0
1
√27𝑟 + 1 ,0 < 𝑥 ≤
𝐹 −1 (𝑥) = 3
1
10 − √54(1 − 𝑟) , < 𝑥 < 1
3
{1 ,𝑥 ≥ 1
1 1
𝑟𝑖 √27𝑟 + 1 ,0 < 𝑥 ≤ 10 − √54(1 − 𝑥) , < 𝑥 < 1
3 3
0.435 4.476
0.549 5.065
John Mora Carrillo
0.955 8.441
0.799 6.705
0.002 1.734
0.530 4.962
0.426 4.432
0.611 5.416
0.492 4.762
0.291 3.80
7. Given the following cdf for a continuous variable with range from – 3 to 4,
develop a generator for the variable, generate 30 values, and plot a histogram.
0, 𝑥 ≤ −3
1 𝑥
+ , −3<𝑥 ≤0
2 6
𝐹(𝑥) =
1 𝑥2
+ , 0<𝑥≤4
2 32
{1, 𝑥>4
0, 𝑟≤0
1
6𝑟 − 3, 0<𝑟≤
𝐹 −1 (𝑥) = 2
1
√32𝑟 − 16, <𝑟≤1
2
{1, 𝑟>1
1 1
𝑟𝑖 6𝑟 − 3, 0<𝑟≤ √32𝑟 − 16, <𝑟≤1
2 2
0.187 -1.876
0.835 3.272
0.925 3.689
0.643 2.139
0.548 1.234
0.090 -2.460
0.828 3.241
0.053 -2.684
0.421 -0.472
0.956 3.820
0.918 3.656
0.658 2.250
0.239 -1.568
0.315 -1.111
John Mora Carrillo
0.052 -2.688
0.481 -0.112
0.482 -0.109
0.287 -1.278
0.509 0.541
0.691 2.472
0.249 -1.507
0.203 -1.784
0.966 3.861
0.914 3.640
0.796 3.079
0.073 -2.563
0.802 3.110
0.061 -2.635
0.025 -2.851
0.969 3.872
8. Given the cdf F(x) = x4/16 on 0<=x<=2, develop a generator for this
distribution. Generate 10 values of the random variable.
𝑥4
𝐹(𝑥) = ; 0≤𝑟≤2
16
4
𝐹 −1 (𝑥) = 2 √𝑟 ; 0≤𝑟≤1
4
𝑟𝑖 2 √𝑟 ; 0 ≤ 𝑟 ≤ 1
0.296 1.474
0.930 1.964
0.602 1.761
0.835 1.911
0.418 1.608
John Mora Carrillo
0.083 1.072
0.112 1.155
0.393 1.583
0.804 1.893
0.266 1.435
9. Data have been collected on service times at a drive-in bank window at the
Shady Lane National Bank. These data are summarized into intervals as
follows:
Consider:
𝑟1 = 0.75, 𝑟1 is contained in the interval (90,120). 𝑖 = 5
𝑋1 = 90 + 150(0.75 − 0.60)
𝑋1 = 112.50 𝑠
𝑋5 = 60 + 130.43(0.43 − 0.37)
𝑋5 = 67.82 𝑠
10. Lead times have been found to be exponentially distributed with mean 3.7 days.
Generate five random lead times from this distribution.
0, 𝑥 ≤ 0
𝐹(𝑥) = { −𝜆𝑥
1 − 𝑒 ,𝑥 > 0
0, 𝑥≤0
−1 (𝑥) 1
𝐹 ={
− ln (1 − 𝑟), 𝑥>0
𝜆
𝑟𝑖 𝑋𝑖
0.75 0.37
0.83 0.48
0.48 0.41
0.93 0.72
0.43 0.15