#C9.txt: How to gamble if you must, Feb. 19, 2015 Help:=proc(): print(`TS(N), Bos(N), GRvG(N,a,p,L)`): print(`GrG(N,a,p,L), GRsimG(N,a,p,K,L) , PrEG(N,p,L), BvsT1(N,p):`): print(`BvsT(N,p) ,TvsB(N,p)`): end: ###old stuff from C8.txt #Feb. 16, 2015, C8.txt, Why you should not gamble! Help8:=proc(): print(`CT(p), GRv(N,a,p), GR(N,a,p) `): print(`GRsim(N,a,p,K) , PrE(N,p)`): end: #CT(p): inputs a rational prob. p, and outputs #+1 with prob. p and -1 with prob. 1-p CT:=proc(p) local n,d,ra: n:=numer(p): d:=denom(p): ra:=rand(1..d)(): if ra<=n then 1: else -1: fi: end: #GRv(N,a,p): Verbose version #simulating, verbosely, a gambler who enters #a casino with a dollars where the stakes are always 1 dollar, #and at each round wins a dollar with prob. p #and has to pay a dollar with prob. 1-p GRv:=proc(N,a,p) local t, c,tos: c:=a: if p<1/2 then print(`You stupidly enter the casino with`, a, `dollars `): print(`hoping to exit with the max`, N, `dollars `): elif p=1/2 then print(`You enter the casino with`, a, `dollars `): print(`hoping to exit with the max`, N, `dollars `): elif p>1/2 then print(`You wisely enter the casino with`, a, `dollars `): print(`hoping to exit with the max`, N, `dollars `): fi: for t from 1 while (c>0 and c0 and c1/2 then print(`You wisely enter the casino with`, a, `dollars `): print(`hoping to exit with the max`, N, `dollars `): fi: for t from 1 while (c>0 and c0 and c 0), N1=4..N)}={true}): end: #TvsB(N,p): proves that for every 4<=N1<=N #it is always better to timid if p>1/2 TvsB:=proc(N,p) local N1: evalb({seq( evalb(TvsB1(N1,p) > 0), N1=4..N)}={true}): end: