/* The Red and the Black in Picat. From Martin Gardner (via Julian Simon): """ Problem 1.5: The Red and the Black (from Gardner, 1983, p. 42)) "Shuffle a packet of four cards - two red, two black - and deal them face down in a row. Two cards are picked at random, say by placing a penny on each. What is the probability that those two cards are the same color?" """ Cf my Gamble model gamble_the_red_and_the_black.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 : pick2 Probabilities: [black,red]: 0.3352000000000000 [red,black]: 0.3307000000000000 [red,red]: 0.1703000000000000 [black,black]: 0.1638000000000000 mean = [[black,red] = 0.3352,[red,black] = 0.3307,[red,red] = 0.1703,[black,black] = 0.1638] var : p Probabilities: false: 0.6659000000000000 true: 0.3341000000000000 mean = [false = 0.6659,true = 0.3341] */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean % , % show_percentiles,show_histogram, % show_hpd_intervals,hpd_intervals=[0.94], % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => Cards = [red,red,black,black], Pick2 = draw_without_replacement(2,Cards), P = check( Pick2.first == Pick2.second), add("pick2",Pick2), add("p",P).