#C16.txt: March 23, 2020 virtual class #The Gambler's ruin's problem Help:=proc(): print(` GRsim1(N,p,n) , GRsim(N,p,n,M,s,t) `): end: with(Statistics): #GRsim1(N,p,n): Simulating ONE Gambler's ruin game with initial capital of n dollars, #At each turn the gambler's win a dollar with probability p and loses a dollar with probability 1-p #the game ends as soon as it reaches N dollars or 0 dollars (when the gambler's is ruined). #The output is a pair [0,m] or [1,m], according to whether the gambler's left the casino broke or #rich, and m is the number of rounds. Try: #GRsim1(10,1/2,5); #GRsim1(10,10/21,5); GRsim1:=proc(N,p,n) local x,U,coin,count: U:=RandomVariable(Bernoulli(p)): x:=n: count:=0: while x>0 and x