/* Bugs book example 2.4.1 Transformation in Picat. Cf my Gamble model gamble_bugs_book_2_4_1.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 : p10 Probabilities: false: 0.7231000000000000 true: 0.2769000000000000 mean = [false = 0.7231,true = 0.2769] HPD intervals: show_hpd_intervals: data is not numeric var : y Probabilities (truncated): 509.531914367826516: 0.0001000000000000 412.444264558721386: 0.0001000000000000 409.362911610060223: 0.0001000000000000 372.156640358727657: 0.0001000000000000 ......... -204.419069361638179: 0.0001000000000000 -220.770224992962142: 0.0001000000000000 -234.403807044124875: 0.0001000000000000 -271.912507637484111: 0.0001000000000000 mean = 12.4619 HPD intervals: HPD interval (0.84): -11.70512322128070..39.18030029671765 var : z Probabilities (truncated): 3.493562338352659: 0.0001000000000000 3.221846240016826: 0.0001000000000000 3.212554478857002: 0.0001000000000000 3.096487830930652: 0.0001000000000000 ......... -3.445396772531768: 0.0001000000000000 -3.521923767488838: 0.0001000000000000 -3.582891388681194: 0.0001000000000000 -3.7392644095049: 0.0001000000000000 mean = -0.00352527 HPD intervals: HPD interval (0.84): -1.44174426750184..1.32977645195029 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean,show_hpd_intervals,hpd_intervals=[0.84]]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => Z = normal_dist(0,1), Y = ((2 * Z) + 1) ** 3, P10 = check(Y > 10), add("p10",P10), add("y",Y), add("z",Z).