/* Bridge in Picat. From Statistics101 (Resampling Stats) """ What is the probability of getting a total of 15 points in a bridge hand when ace = 4, king =3, queen = 2, and jack = 1. From Simon, "The New Statistics", p 126 -> probability: 0.04404 """ Cf my Gamble model gamble_bridge.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 : s Probabilities (truncated): 8: 0.0866000000000000 9: 0.0849000000000000 10: 0.0837000000000000 7: 0.0774000000000000 ......... 29: 0.0003000000000000 33: 0.0001000000000000 30: 0.0001000000000000 26: 0.0001000000000000 mean = 10.0435 var : p Probabilities: false: 0.9562000000000000 true: 0.0438000000000000 mean = [false = 0.9562,true = 0.0438] */ go ?=> reset_store, Deck = ones(4,4) ++ ones(4,3) ++ ones(4,2) ++ ones(4,1) ++ ones(36,0), run_model(10_000,$model(Deck),[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go => true. model(Deck) => Hand = resample(13,Deck), S = Hand.sum, P = check(S == 15), add("s",S), add("p",P).