#Nathan Fox #Homework 14 #I give permission for this file to be posted online ##Read old files read(`C14.txt`): #Help procedure Help:=proc(): print(` SheppConstant(n) , PrWinBreakEvenLose(m,p) `): print(` gammah(m), BoyceCheck(cap) `): end: ##Problem 1 #SheppConstant(p): inputs a value of p and outputs the corresponding #estimate of Shepp's Constant SheppConstant:=proc(p): evalf((beta(p)-p)/sqrt(2*p)): end: #SheppConstant(1000) returns 0.8273451515 ##Problem 2 #PrWinBreakEvenLose(m,p): inputs two positive integers m and p #and outputs a list of length 3 whose first entry is the #probability of exiting with a positive amount, zero amount, #and negative amouts, respectively. PrWinBreakEvenLose:=proc(m,p) local pdist, L, pos, neg, zero: pdist:=PrDist(m,p): pos:=0: neg:=0: zero:=0: for L in pdist do: if L[1] > 0 then pos:=pos + L[2]: elif L[1] < 0 then neg:=neg + L[2]: else zero:=zero + L[2]: fi: od: [pos,zero,neg]: end: #It appears that the probability of losing in #PrWinBreakEvenLose(beta(p),p) decreases as p increases, and the #probability of winning increases. Hence, for this game, the #"maximize expectation" strategy is a good one. ##Problem 3 #gammah(m): The smallest p for which Larry(m,p) is nonnegative #not called gamma, because gamma is reserved gammah:=proc(m) local p: for p from 0 while Larry(m,p)<=0 do od: p: end: #BoyceCheck(cap): inputs a cap to check up to and returns the set #of triples [m,p,code] where one of Boyce's #inequalities fails. An empty set returned means that the #inequalities hold. The code indicates which inequality failed. #It will be one of T31a, T31b, T31c, T32a, T32b, or T32c BoyceCheck:=proc(cap) local m, p, ret: ret:={}: for m from 0 to cap do: for p from 0 to cap do: #Theorem 3.1 a if Larry(m,p) >= 0 and LarryE(m,p+1)LarryE(m,p)+1 then ret:=ret union {[m,p,`T31b`]}: fi: #Theorem 3.1 c if p>gammah(m) and LarryE(m,p+1)= 0 and LarryE(m,p)LarryE(m+1,p)+1 then ret:=ret union {[m,p,`T32b`]}: fi: #Theorem 3.2 c if p>gammah(m+1) and LarryE(m,p)