chutes and ladders (0,100) probability from P^n and probability of ending game on the nth roll (0,100) Pr(game ends n from P^n on nth roll) 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7.0000 0.0020 0.0020 8.0000 0.0081 0.0062 9.0000 0.0183 0.0102 10.0000 0.0318 0.0135 11.0000 0.0489 0.0171 12.0000 0.0694 0.0205 13.0000 0.0917 0.0223 14.0000 0.1149 0.0232 15.0000 0.1388 0.0239 16.0000 0.1639 0.0251 17.0000 0.1902 0.0263 18.0000 0.2173 0.0271 19.0000 0.2448 0.0274 20.0000 0.2722 0.0275 21.0000 0.2996 0.0274 22.0000 0.3268 0.0272 23.0000 0.3535 0.0267 24.0000 0.3796 0.0261 25.0000 0.4049 0.0253 26.0000 0.4293 0.0244 27.0000 0.4528 0.0236 28.0000 0.4756 0.0227 29.0000 0.4975 0.0219 30.0000 0.5185 0.0210 31.0000 0.5387 0.0202 32.0000 0.5580 0.0194 33.0000 0.5766 0.0186 34.0000 0.5944 0.0178 35.0000 0.6115 0.0171 36.0000 0.6278 0.0164 37.0000 0.6435 0.0157 38.0000 0.6585 0.0150 39.0000 0.6729 0.0144 40.0000 0.6867 0.0138 41.0000 0.6999 0.0132 42.0000 0.7126 0.0127 43.0000 0.7247 0.0121 44.0000 0.7363 0.0116 45.0000 0.7474 0.0111 46.0000 0.7581 0.0107 47.0000 0.7683 0.0102 48.0000 0.7781 0.0098 49.0000 0.7874 0.0094 50.0000 0.7964 0.0090 51.0000 0.8050 0.0086 52.0000 0.8132 0.0082 53.0000 0.8211 0.0079 54.0000 0.8287 0.0075 55.0000 0.8359 0.0072 56.0000 0.8428 0.0069 57.0000 0.8494 0.0066 58.0000 0.8558 0.0064 59.0000 0.8619 0.0061 60.0000 0.8677 0.0058 61.0000 0.8733 0.0056 62.0000 0.8786 0.0053 63.0000 0.8838 0.0051 64.0000 0.8887 0.0049 65.0000 0.8934 0.0047 66.0000 0.8979 0.0045 67.0000 0.9022 0.0043 68.0000 0.9063 0.0041 69.0000 0.9103 0.0040 70.0000 0.9140 0.0038 71.0000 0.9177 0.0036 72.0000 0.9211 0.0035 73.0000 0.9245 0.0033 74.0000 0.9277 0.0032 75.0000 0.9307 0.0031 76.0000 0.9336 0.0029 77.0000 0.9364 0.0028 78.0000 0.9391 0.0027 79.0000 0.9417 0.0026 80.0000 0.9441 0.0025 81.0000 0.9465 0.0024 82.0000 0.9488 0.0023 83.0000 0.9509 0.0022 84.0000 0.9530 0.0021 85.0000 0.9550 0.0020 86.0000 0.9569 0.0019 87.0000 0.9587 0.0018 88.0000 0.9604 0.0017 89.0000 0.9621 0.0017 90.0000 0.9637 0.0016 91.0000 0.9652 0.0015 92.0000 0.9667 0.0015 93.0000 0.9681 0.0014 94.0000 0.9695 0.0013 95.0000 0.9707 0.0013 96.0000 0.9720 0.0012 97.0000 0.9732 0.0012 98.0000 0.9743 0.0011 99.0000 0.9754 0.0011 100.0000 0.9764 0.0010 101.0000 0.9774 0.0010 102.0000 0.9784 0.0010 103.0000 0.9793 0.0009 104.0000 0.9802 0.0009 105.0000 0.9810 0.0008 106.0000 0.9818 0.0008 107.0000 0.9826 0.0008 108.0000 0.9833 0.0007 109.0000 0.9840 0.0007 110.0000 0.9847 0.0007 111.0000 0.9853 0.0006 112.0000 0.9859 0.0006 113.0000 0.9865 0.0006 114.0000 0.9871 0.0006 115.0000 0.9876 0.0005 116.0000 0.9882 0.0005 117.0000 0.9887 0.0005 118.0000 0.9891 0.0005 119.0000 0.9896 0.0005 120.0000 0.9900 0.0004 121.0000 0.9905 0.0004 122.0000 0.9909 0.0004 123.0000 0.9912 0.0004 124.0000 0.9916 0.0004 125.0000 0.9920 0.0004 126.0000 0.9923 0.0003 127.0000 0.9926 0.0003 128.0000 0.9929 0.0003 129.0000 0.9932 0.0003 130.0000 0.9935 0.0003 131.0000 0.9938 0.0003 132.0000 0.9941 0.0003 133.0000 0.9943 0.0003 134.0000 0.9946 0.0002 135.0000 0.9948 0.0002 136.0000 0.9950 0.0002 137.0000 0.9952 0.0002 138.0000 0.9954 0.0002 139.0000 0.9956 0.0002 140.0000 0.9958 0.0002 141.0000 0.9960 0.0002 142.0000 0.9961 0.0002 143.0000 0.9963 0.0002 144.0000 0.9965 0.0002 145.0000 0.9966 0.0001 146.0000 0.9968 0.0001 147.0000 0.9969 0.0001 148.0000 0.9970 0.0001 149.0000 0.9971 0.0001 150.0000 0.9973 0.0001 151.0000 0.9974 0.0001 152.0000 0.9975 0.0001 153.0000 0.9976 0.0001 154.0000 0.9977 0.0001 155.0000 0.9978 0.0001 156.0000 0.9979 0.0001 157.0000 0.9980 0.0001 158.0000 0.9981 0.0001 159.0000 0.9981 0.0001 160.0000 0.9982 0.0001 161.0000 0.9983 0.0001 162.0000 0.9984 0.0001 163.0000 0.9984 0.0001 164.0000 0.9985 0.0001 165.0000 0.9986 0.0001 166.0000 0.9986 0.0001 167.0000 0.9987 0.0001 168.0000 0.9987 0.0001 169.0000 0.9988 0.0001 170.0000 0.9988 0.0001 171.0000 0.9989 0.0000 172.0000 0.9989 0.0000 173.0000 0.9990 0.0000 174.0000 0.9990 0.0000 175.0000 0.9991 0.0000 176.0000 0.9991 0.0000 177.0000 0.9991 0.0000 178.0000 0.9992 0.0000 179.0000 0.9992 0.0000 180.0000 0.9993 0.0000 181.0000 0.9993 0.0000 182.0000 0.9993 0.0000 183.0000 0.9993 0.0000 184.0000 0.9994 0.0000 185.0000 0.9994 0.0000 186.0000 0.9994 0.0000 187.0000 0.9994 0.0000 188.0000 0.9995 0.0000 189.0000 0.9995 0.0000 190.0000 0.9995 0.0000 191.0000 0.9995 0.0000 192.0000 0.9996 0.0000 193.0000 0.9996 0.0000 194.0000 0.9996 0.0000 195.0000 0.9996 0.0000 196.0000 0.9996 0.0000 197.0000 0.9996 0.0000 198.0000 0.9997 0.0000 199.0000 0.9997 0.0000 200.0000 0.9997 0.0000 201.0000 0.9997 0.0000 202.0000 0.9997 0.0000 203.0000 0.9997 0.0000 204.0000 0.9997 0.0000 205.0000 0.9997 0.0000 206.0000 0.9998 0.0000 207.0000 0.9998 0.0000 208.0000 0.9998 0.0000 209.0000 0.9998 0.0000 210.0000 0.9998 0.0000 211.0000 0.9998 0.0000 212.0000 0.9998 0.0000 213.0000 0.9998 0.0000 214.0000 0.9998 0.0000 215.0000 0.9998 0.0000 216.0000 0.9998 0.0000 217.0000 0.9998 0.0000 218.0000 0.9999 0.0000 219.0000 0.9999 0.0000 220.0000 0.9999 0.0000 221.0000 0.9999 0.0000 222.0000 0.9999 0.0000 223.0000 0.9999 0.0000 224.0000 0.9999 0.0000 225.0000 0.9999 0.0000 226.0000 0.9999 0.0000 227.0000 0.9999 0.0000 228.0000 0.9999 0.0000 229.0000 0.9999 0.0000 230.0000 0.9999 0.0000 231.0000 0.9999 0.0000 232.0000 0.9999 0.0000 233.0000 0.9999 0.0000 234.0000 0.9999 0.0000 235.0000 0.9999 0.0000 236.0000 0.9999 0.0000 237.0000 0.9999 0.0000 238.0000 0.9999 0.0000 239.0000 0.9999 0.0000 240.0000 0.9999 0.0000 241.0000 0.9999 0.0000 242.0000 0.9999 0.0000 243.0000 1.0000 0.0000 244.0000 1.0000 0.0000 245.0000 1.0000 0.0000 246.0000 1.0000 0.0000 247.0000 1.0000 0.0000 248.0000 1.0000 0.0000 249.0000 1.0000 0.0000 250.0000 1.0000 0.0000 251.0000 1.0000 0.0000 252.0000 1.0000 0.0000 253.0000 1.0000 0.0000 254.0000 1.0000 0.0000 255.0000 1.0000 0.0000 256.0000 1.0000 0.0000 257.0000 1.0000 0.0000 258.0000 1.0000 0.0000 259.0000 1.0000 0.0000 260.0000 1.0000 0.0000 261.0000 1.0000 0.0000 262.0000 1.0000 0.0000 263.0000 1.0000 0.0000 264.0000 1.0000 0.0000 265.0000 1.0000 0.0000 266.0000 1.0000 0.0000 267.0000 1.0000 0.0000 268.0000 1.0000 0.0000 269.0000 1.0000 0.0000 270.0000 1.0000 0.0000 271.0000 1.0000 0.0000 272.0000 1.0000 0.0000 273.0000 1.0000 0.0000 274.0000 1.0000 0.0000 275.0000 1.0000 0.0000 276.0000 1.0000 0.0000 277.0000 1.0000 0.0000 278.0000 1.0000 0.0000 279.0000 1.0000 0.0000 280.0000 1.0000 0.0000 281.0000 1.0000 0.0000 282.0000 1.0000 0.0000 283.0000 1.0000 0.0000 284.0000 1.0000 0.0000 285.0000 1.0000 0.0000 286.0000 1.0000 0.0000 287.0000 1.0000 0.0000 288.0000 1.0000 0.0000 289.0000 1.0000 0.0000 290.0000 1.0000 0.0000 291.0000 1.0000 0.0000 292.0000 1.0000 0.0000 293.0000 1.0000 0.0000 294.0000 1.0000 0.0000 295.0000 1.0000 0.0000 296.0000 1.0000 0.0000 297.0000 1.0000 0.0000 298.0000 1.0000 0.0000 299.0000 1.0000 0.0000 300.0000 1.0000 0.0000 approximation to E(T|Xo=0) using the game ending probabilities 36.1917 approximation to Var(T|Xo=0) using the game ending probabilities and the estimated E(T|Xo=0) 562.8996 ===================================================== diary 'chutespn.out' ; format compact; disp('chutes and ladders') x = zeros(100,100); % CREATE THE PROBABILITY TRANSITION MATRIX ; for r = 1:94; for c = 1:6 ; x(r,r+c) = 1; end; end; x(96:100,97:100) = [ 1 0 1 3; 0 0 1 4; 0 0 0 0; 0 0 0 6; 0 0 0 6]; dlt = [98 95 93 87 80 71 64 62 56 51 49 48 36 28 21 16 9 4 1]; for i=0:5; x(3+i,31) = 1; x(3+i,9) =0; x(10+i,6) = 1; x(10+i,16)=0; x(15+i,42) = 1; x(15+i,21)=0; x(22+i,84) = 1; x(22+i,28)=0; x(30+i,44) = 1; x(30+i,36)=0; x(42+i,26) = 1; x(42+i,48)=0; x(43+i,11) = 1; x(43+i,49)=0; x(45+i,67) = 1; x(45+i,51)=0; x(50+i,53) = 1; x(50+i,56)=0; x(56+i,19) = 1; x(56+i,62)=0; x(58+i,60) = 1; x(58+i,64)=0; x(65+i,91) = 1; x(65+i,71)=0; x(74+i,100)= 1; x(74+i,80)=0; x(81+i,24) = 1; x(81+i,87)=0; x(87+i,73) = 1; x(87+i,93)=0; x(89+i,75) = 1; x(89+i,95)=0; x(92+i,78) = 1; x(92+i,98)=0; end; x(50,53)=2; x(52,53)=2; x(58,60)=2; x(59,60)=2; jr = zeros(1,100); x(2,14)=1; x(3,14)=1; x(3,31)=1; x = [jr ; x]; jc = zeros(101,1); x(1,1:6) = [ 0 1 1 0 1 1]; x(1,38)=1; x(1,14)=1; x = [jc x]; for d = 1:19; rc = dlt(1,d); x(rc+1,:) = []; x(:,rc+1) = []; end; x = x/6; Pn = x; tmp = 0; mn=0; pvec = zeros(300,1); pvec(1,1)=0; disp('(0,100) probability from P^n'); disp('and probability of ending game'); disp('on the nth roll'); disp(' (0,100) Pr(game ends'); disp(' n from P^n on nth roll)'); xx = [1 0 0]; disp(xx); iter=300; for n = 2:iter; Pn = Pn*x; rn = Pn(1,82); exact = rn - tmp; pvec(n,1) = exact; mn = mn + n*exact; xx = [n rn exact]; tmp = rn; disp(xx) end; disp('approximation to E(T|Xo=0)'); disp('using the game ending probabilities'); disp(mn); var = 0; for i=1:iter; var = var + pvec(i,1)*((i-mn)^2); end; disp('approximation to Var(T|Xo=0)'); disp('using the game ending probabilities'); disp('and the estimated E(T|Xo=0)'); disp(var); end;