/* Meeting under the clock (Julian Simon) in Picat. """ Meeting Under the Clock (This problem is posed by Julian Simon(1994)) Two persons agree to arrive at the two clock sometime between 1 pm and 2 pm and to stay for 20 minutes. What is the probability that they will be there at the same time? """ Here we use overlap instead of abs(), Cf - ppl_meeting_under_the_clock.pi - my Gamble model gamble_meeting_under_the_clock2.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 : c1 Probabilities (truncated): 55: 0.0194000000000000 44: 0.0191000000000000 35: 0.0191000000000000 57: 0.0189000000000000 ......... 48: 0.0144000000000000 27: 0.0144000000000000 19: 0.0143000000000000 45: 0.0139000000000000 mean = 30.6126 var : c2 Probabilities (truncated): 30: 0.0190000000000000 3: 0.0189000000000000 36: 0.0187000000000000 18: 0.0187000000000000 ......... 57: 0.0148000000000000 41: 0.0146000000000000 34: 0.0141000000000000 12: 0.0140000000000000 mean = 30.4232 var : prob Probabilities: true: 0.5629000000000000 false: 0.4371000000000000 mean = [true = 0.5629,false = 0.4371] */ 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. overlap(A1,A2,B1,B2) = cond(max(A1,B1) <= min(A2,B2),true,false). model() => WaitTime = 20, C1 = random_integer1(60), C2 = random_integer1(60), Prob = check( overlap(C1,C1+WaitTime,C2,C2+WaitTime) == true), add("c1",C1), add("c2",C2), add("prob",Prob).