/* One spade or one club in Picat. From http://www.statistics101.net/statistics101web_000007.htm """ From CliffsQuickReview Statistics, p. 41, example 3 What is the probability of at least one spade or one club being randomly chosen in one draw from a deck of cards? Calculated result: 13/52 + 13/52 = 0.5. """ Cf my Gamble model gamble_one_spade_or_one_club.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 : card Probabilities: heart: 0.2551000000000000 spade: 0.2518000000000000 club: 0.2492000000000000 diamond: 0.2439000000000000 mean = [heart = 0.2551,spade = 0.2518,club = 0.2492,diamond = 0.2439] var : p Probabilities: true: 0.5010000000000000 false: 0.4990000000000000 mean = 0.501 */ 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(13,spade) ++ ones(13,club) ++ ones(13,heart) ++ ones(13,diamond), Card = draw_without_replacement(1,Deck).first, P = check( (Card == spade ; Card == club)), add("card",Card), add("p",P).