/* Two coins in Picat. This is a port of the R2 model TwoCoins.cs Output from the R2 model: ''' (0) Mean: 0.339 firstCoin (0) Variance: 0.224303 (1) Mean: 0.309 secondCoin (1) Variance: 0.213733 Number of accepted samples = 847 ''' Cf my Gamble model gamble_two_coins.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 : first coin Probabilities: false: 0.6610147213459516 true: 0.3389852786540484 mean = 0.338985 var : second coin Probabilities: false: 0.6728443743427971 true: 0.3271556256572030 mean = 0.327156 var : both heads Probabilities: false: 1.0000000000000000 mean = 0.0 */ 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() => FirstCoin = flip(1/2), SecondCoin = flip(1/2), BothHeads = check( (FirstCoin, SecondCoin)), observe(not BothHeads), if observed_ok then add("first coin",FirstCoin), add("second coin",SecondCoin), add("both heads",BothHeads), end.