/* One ace in Picat. From Statistics101 (Resampling Stats) oneAce.txt """ What is the probability of getting exactly one ace of any suit in a 5-card hand? -> prob: 0.3001 prob: 0.3073 prob: 0.2919 """ Cf my Gamble model gamble_one_ace.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: 0: 0.6603000000000000 1: 0.2989000000000000 2: 0.0389000000000000 3: 0.0019000000000000 mean = 0.3824 var : p Probabilities: false: 0.7010999999999999 true: 0.2989000000000000 mean = 0.2989 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean % , % show_percentiles, % show_hpd_intervals,hpd_intervals=[0.94], % show_histogram, % min_accepted_samples=1000,show_accepted_samples=true ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => Deck = ones(4,1..13).flatten, Hand = draw_without_replacement(5,Deck), S = count_occurrences(1,Hand), % How many aces? P = check(S == 1), add("s",S), add("p",P).