#Feb. 16, 2015, C8.txt, Why you should not gamble! Help:=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 c