/* An experiment in Personal Taste for Money (Mosteller) in Picat. From Mosteller "Fifty Challenging problems in Probability" """ 10. An Experiment in Personal Taste for Money (a) An urn contains 10 black balls and 10 white balls, identical except for color. You choose "black" or "white." One ball is drawn at random. and if its color matches your choice. you get $10. otherwise nothing. Write down the maximum amount you are willing to pay to play the game. The game will be played just once. (b) A friend of yours has available many black and many white balls. and he puts black and white balls into the urn to suit himself. You choose "black" or "white." A ball is drawn randomly from this urn. Write down the maximum amount you are willing to pay to play this game. The game will be played just once. """ Cf my Gamble model gamble_an_experiment_in_personal_taste_for_money.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. /* var : draw Probabilities: black: 0.5024999999999999 white: 0.4975000000000000 mean = [] var : outcome Probabilities: 0: 0.5024999999999999 10: 0.4975000000000000 mean = 4.975 */ go ?=> reset_store, run_model(10_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() => Selected = white, Urn = rep(10,black) ++ rep(10,white), Draw = uniform_draw(Urn), Outcome = cond(Selected == Draw,10,0), add("draw",Draw), add("outcome",Outcome). /* b) Second part If the friend selects randomly between equally number of black and white balls, it's the same outcome as in a). However, if there are a different number of available of white and black balls, then it's a little different outcome. For example if the friend has 10 black balls and 20 white balls and random select at least one from each and then randomly some more, the outcome is: var : draw Probabilities: white: 0.6227000000000000 black: 0.3773000000000000 mean = [] var : outcome Probabilities: 10: 0.6227000000000000 0: 0.3773000000000000 mean = 6.227 */ go2 ?=> reset_store, run_model(10_000,$model2,[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. go2 => true. model2() => NumBlack = random_integer1(10), NumWhite = random_integer1(20), Selected = white, Urn = rep(NumBlack,black) ++ rep(NumWhite,white), Draw = uniform_draw(Urn), Outcome = cond(Selected == Draw,10,0), add("draw",Draw), add("outcome",Outcome).