#C26.txt, Gambler's ruin, April 28, 2014 Help:=proc(): print(`Die1(p), GR(i,N,p), ExpD(N,p)`): print(`ExpDf(N,p) , PGF(N,p,t), PGFf(N,p,t), GuessP(L,x) `): end: #Die1: inputs p rational between 0 and 1 #and outputs 1 with prob. p and 0 with prob. 1-p Die1:=proc(p) local a,b,ra: a:=numer(p): b:=denom(p): ra:=rand(1..b)(): if ra<=a then 1: else -1: fi: end: #GR(i,N,p): simulates a gambler's ruin session #staring with i dollars, ending with 0 or N dollars #and with prob. of winning a dollar =p GR:=proc(i,N,p) local x,j: x:=i: for j from 0 while (x>0 and xFAIL then RETURN(gu): fi: od: FAIL: end: #end Added after class