/* Where is my bag? in Picat. From "Probabilistic Reasoning Under Uncertainty with Bayesian Networks" https://www.bayesia.com/2018-03-02-probabilistic-reasoning-under-uncertainty (Also see The BaysiaLabBook "Bayesian Networks BayesiaLab" v1, page 51f.) Travel from Singapore -> Tokyo -> Los Angeles. 1) The departure of Singapore -> Tokyo is delayed 2) Just made the Tokyo -> LA trip. There's a 50/50 change the luggage is on the plane to LA. 3) Arriving at LA, waiting for the luggage in 5 minutes, the luggage has not been seen. What is the probability that the bag was in the Tokyo -> LA plane? Answer: The probability that the bag was with the LA plane is 33% (as in the talk). From Judea Pearl: The Book of Why. Exact probabilities from my Gamble model: (bag-on-plane-p 1/2 wait-time 5) (#f : 2/3 (0.6666666666666666)) (#t : 1/3 (0.3333333333333333)) (bag-on-plane-p 1/2 wait-time 8) (#f : 5/6 (0.8333333333333334)) (#t : 1/6 (0.16666666666666666)) (bag-on-plane-p 4/5 wait-time 5) (#t : 2/3 (0.6666666666666666)) (#f : 1/3 (0.3333333333333333)) (bag-on-plane-p 4/5 wait-time 8) (#f : 5/9 (0.5555555555555556)) (#t : 4/9 (0.4444444444444444)) This is a port of my Racket/Gamble model gamble_where_is_my_bag.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. main => go. /* [bag_on_plane_p = 0.5,wait_time = 5] var : bag on the plane Probabilities: false: 0.65889735544598838 (1470 / 2231) true: 0.34110264455401168 (761 / 2231) [bag_on_plane_p = 0.5,wait_time = 8] var : bag on the plane Probabilities: false: 0.82537067545304776 (501 / 607) true: 0.17462932454695224 (106 / 607) [bag_on_plane_p = 0.8,wait_time = 5] var : bag on the plane Probabilities: true: 0.66647887323943666 (1183 / 1775) false: 0.33352112676056339 (592 / 1775) [bag_on_plane_p = 0.8,wait_time = 8] var : bag on the plane Probabilities: false: 0.57212003872216843 (591 / 1033) true: 0.42787996127783157 (442 / 1033) */ go ?=> member([BagOnPlaneP,WaitTime], [[1/2,5], [1/2,8], [8/10,5], [8/10,8] ]), println([bag_on_plane_p=BagOnPlaneP,wait_time=WaitTime]), reset_store, run_model(30_000,$model(BagOnPlaneP,WaitTime),[show_probs_rat]), fail, nl. go => true. model(BagOnPlaneP,WaitTime) => MaxTime = 10, % We know that the bag was on the plane with 50% probability. % Variant: https://www.youtube.com/watch?v=c71pnonOMkI&t=1074s it's 80/20. BagOnPlane = flip(BagOnPlaneP), % We assume uniform time step TTime = random_integer(MaxTime), % 0..MaxTime-1 % Probability that the bag is on the carousel given a specific time % (if it was on the plane, that is). % The probability that the bag is on the carousel on a given time % is directly proportional on the time: % time / maxTime BagOnCarousel = cond(BagOnPlane == true, flip(TTime / MaxTime), false), % He waited 5 minutes without seeing the luggage. % Is the bag on the plane? % add("bag on the carousel",BagOnCarousel), % add("t-time",TTime), observe(TTime == WaitTime, BagOnCarousel == false), if observed_ok then add("bag on the plane",BagOnPlane), % add("p",1) else true % add("p",0) end.