/* Random walk roulette (Mosteller) in Picat. From Mosteller "Fifty Challenging Problem in Probability" """ 7. Curing the Compulsive Gambler Mr. Brown always bets a dollar on the number 13 at roulette against the advice of Kind Friend To help cure Mr Brown of playing roulette, Kind Friend always bets Brown $20 at even money that Brown will be behind at the end of 36 plays. How is the cure working? (Most American roulette wheels have 38 equally likely numbers. If the player's number comes up, he is paid 35 times his stake and gets his original stake back; otherwise he loses his stake) ... And so all told Mr. Brown gains +4.68 - 1.89 = +2.79 dollars per 36 trials; he is finally making money at roulette. Possibly Kind Friend will be cured first. Of course, when Brown loses all 36, he is out $56, which may jolt him a bit. """ According to this model: Estimated gain of Mr. Brown is $3.875400000000003, and of Kind Friend: $-4.792000000000001 Cf my Gamble model gamble_random_walk_roulette.rkt This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import ppl_distributions, ppl_utils. import util. % import ordset. main => go. /* According to this model: Estimated gain of Mr. Brown is $3.8195, and of Kind Friend: $-4.688 var : final Probabilities: -36: 0.3828000000000000 1: 0.3694500000000000 38: 0.1797500000000000 75: 0.0540000000000000 112: 0.0118000000000000 149: 0.0018500000000000 186: 0.0003500000000000 mean = -0.8685 var : outcome Probabilities: false: 0.6172000000000000 true: 0.3828000000000000 mean = 0.3828 var : brown Probabilities: -56: 0.3828000000000000 21: 0.3694500000000000 58: 0.1797500000000000 95: 0.0540000000000000 132: 0.0118000000000000 169: 0.0018500000000000 206: 0.0003500000000000 mean = 3.8195 var : kind friend Probabilities: -20: 0.6172000000000000 20: 0.3828000000000000 mean = -4.688 */ go ?=> reset_store, run_model(20_000,$model,[show_probs_trunc,mean % , % show_simple_stats % , % show_percentiles, % show_hpd_intervals,hpd_intervals=[0.84,0.9,0.94,0.99,0.99999], % show_histogram, % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => N = 36, % 36 plays Final = [cond(random_integer1(38)==13,36,-1) : _ in 1..N].sum, Outcome = check(Final < 0), Brown = Final + cond(Final > 0,20,-20), KindFriend = cond(Final < 0, 20,-20), add("final",Final), add("outcome",Outcome), add("brown",Brown), add("kind friend",KindFriend).