#Please do NOT post homework #Julian Herman, 9/27/21, Assignment 7 #1) #Runs GRt K times and returns the [ProbabilityOfExitingAwinner, AverageDurationOfGame] EstGR:=proc(p,i,N,K) local s,d,j,A: s:=0: d:=0: for j from 1 to K do A:=GRt(p,i,N): if A[1]=1 then s:=s+1: end if: d:=d+A[2]: end do: return [evalf(s/K), evalf(d/K)] end proc: #3) #outputs the EXACT pair [ProbabilityOfExitingAwinner , AverageDuration] for any i and N where 0≤i≤N ExactFairGR:=proc(i,N): return [evalf(i/N), evalf(i*(N-i))] end proc: for i to 19 do ExactFairGR(i, 20) EstGR(0.5, i, 20, 3000) end do; [0.05000000000, 19.] [0.04533333333, 18.30133333] [0.1000000000, 36.] [0.1000000000, 35.54933333] [0.1500000000, 51.] [0.1490000000, 50.83200000] [0.2000000000, 64.] [0.1880000000, 62.92200000] [0.2500000000, 75.] [0.2493333333, 73.93933333] [0.3000000000, 84.] [0.3076666667, 84.60466667] [0.3500000000, 91.] [0.3476666667, 92.53266667] [0.4000000000, 96.] [0.4133333333, 97.28266667] [0.4500000000, 99.] [0.4456666667, 100.2993333] [0.5000000000, 100.] [0.5013333333, 98.14266667] [0.5500000000, 99.] [0.5553333333, 97.28066667] [0.6000000000, 96.] [0.5923333333, 96.14733333] [0.6500000000, 91.] [0.6486666667, 90.49733333] [0.7000000000, 84.] [0.6956666667, 84.12800000] [0.7500000000, 75.] [0.7490000000, 73.29533333] [0.8000000000, 64.] [0.8023333333, 62.52666667] [0.8500000000, 51.] [0.8520000000, 48.89866667] [0.9000000000, 36.] [0.9066666667, 36.26800000] [0.9500000000, 19.] [0.9480000000, 20.00600000] #4) P := RandSM(10); StSa(P, 4000); [0.1087500000, 0.06925000000, 0.1030000000, 0.08425000000, 0.1080000000, 0.06900000000, 0.1307500000, 0.09625000000, 0.1067500000, 0.1240000000] evalf(StSp(P, 4000)); [0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778, 0.1174173778] evalf(StS(P)); [0.1174173778, 0.07243439021, 0.1033371556, 0.08329597760, 0.1053143503, 0.06188408639, 0.1280674803, 0.09595685853, 0.1089925630, 0.1232997602] #6) EXTRA CREDIT: DID NOT COMPLETE EstimateProbSum:=proc(p1,p2,p3,p4,p5,p6,N1,N2,K1,K2) local i,j,r,a,s: s:=0: for i from 1 to K2 do a:=0: for j from 1 to K1 do r:=rand()/(1000000000000.): if r < p1 then a:=a+1: elif r < p1+p2 then a:=a+2: elif r < p1+p2+p3 then a:=a+3: elif r < p1+p2+p3+p4 then a:=a+4: elif r < p1+p2+p3+p4+p5 then a:=a+5: else a:=a+6: end if: end do: if N1 < a < N2 then s:=s+1: end if: end do: return evalf(s/K2); end proc: