/* BUGS book, 2.1.2 in Picat. Cf my Gamble model gamble_bugs_book_2_1_2.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, ppl_common_utils. import util. % import ordset. main => go. /* var : y Probabilities: 4: 0.2670000000000000 5: 0.2244000000000000 3: 0.2173000000000000 2: 0.1125000000000000 6: 0.1086000000000000 7: 0.0315000000000000 1: 0.0311000000000000 8: 0.0043000000000000 0: 0.0033000000000000 mean = 4.0045 var : p2 Probabilities: false: 0.8531000000000000 true: 0.1469000000000000 mean = 0.1469 theoretical = 0.144531 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean]), println(theoretical=binomial_dist_cdf(8,1/2,2)), nl, % fail, nl. go => true. model() => Y = binomial_dist(8,1/2), P2 = check(Y <= 2), add("y",Y), add("p2",P2).