/* Dartboard in Picat. From Statistics101 (Resample Stats) http://www.statistics101.net/QuickReference.pdf Page 19 """ A dartboard is divided into twenty equal wedges, ignoring the bull's eye. Only six of the twenty wedges are worth points, so the probability of scoring on one throw is 6/20, or 0.3, assuming your throws always hit the board. What is the chance of hitting at least one scoring region in three consecutive throws? (From CliffsQuickReview Statistics, p.48). """ Exact probabilities: s: Picat> pdf_all($binomial_dist(3,6/20)).sort_down(2).printf_list 1 0.441 0 0.343 2 0.189 3 0.027 p: Picat> X=1-binomial_dist_cdf(3,6/20,0) X = 0.657 Cf my Gamble model gamble_dartboard.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. /* Using resampling var : s Probabilities: 1: 0.4380000000000000 0: 0.3417000000000000 2: 0.1932000000000000 3: 0.0271000000000000 mean = 0.9057 var : p Probabilities: true: 0.6583000000000000 false: 0.3417000000000000 mean = [true = 0.6583,false = 0.3417] */ go ?=> ScoreProb = ones(3,score) ++ ones(7,no_score), reset_store, run_model(10_000,$model(ScoreProb),[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go => true. model(ScoreProb) => NumThrows = 3, ThreeThrows = resample(NumThrows,ScoreProb), S = count_occurrences(score,ThreeThrows), P = check(S >= 1), add("s",S), add("p",P). /* Using binomial var : s Probabilities: 1: 0.4377000000000000 0: 0.3515000000000000 2: 0.1853000000000000 3: 0.0255000000000000 mean = 0.8848 var : p Probabilities: true: 0.6485000000000000 false: 0.3515000000000000 mean = [true = 0.6485,false = 0.3515] */ go2 ?=> reset_store, run_model(10_000,$model2,[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go2 => true. model2() => S = binomial_dist(3,6/20), P = check(S >= 1), add("s",S), add("p",P).