/* Medical in Picat. From Church Result: '("cough" #f "fever" #f "chest-pain" #f "shortness-of-breath" #f) Port of my Gamble model gamble_medical.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. /* var : ChestPain Probabilities: false: 1.00000000000000000 (1 / 1) var : Cold Probabilities: false: 0.80349999999999999 (1607 / 2000) true: 0.19650000000000001 (393 / 2000) var : Cough Probabilities: false: 1.00000000000000000 (1 / 1) var : Fever Probabilities: false: 1.00000000000000000 (1 / 1) var : LungCancer Probabilities: false: 0.98999999999999999 (99 / 100) true: 0.01000000000000000 (1 / 100) var : Other Probabilities: false: 0.89949999999999997 (1799 / 2000) true: 0.10050000000000001 (201 / 2000) var : ShortnessOfBeath Probabilities: false: 1.00000000000000000 (1 / 1) var : StomachFlu Probabilities: false: 0.89829999999999999 (8983 / 10000) true: 0.10170000000000000 (1017 / 10000) var : TB Probabilities: false: 0.99419999999999997 (4971 / 5000) true: 0.00580000000000000 (29 / 5000) */ go ?=> reset_store(), run_model(10_000,$model,[show_probs_rat]), % fail, nl. go => true. model() => LungCancer = flip(0.01), TB = flip(0.005), StomachFlu = flip(0.1), Cold = flip(0.2), Other = flip(0.1), Cough = cond(( (Cold,flip(0.5)) ; (LungCancer,flip(0.3)) ; (TB, flip(0.7)) ; (Other, flip(0.01)))==true,true,false), Fever = cond(( (Cold, flip(0.3)) ; (StomachFlu, flip(0.5)) ; (TB, flip(0.1)) ; (Other, flip( 0.01)))==true,true,false), ChestPain = cond(( (LungCancer, flip(0.5)) ; (TB, flip( 0.5)) ; (Other, flip( 0.01)))==true,true,false), ShortnessOfBeath = cond(((LungCancer, flip(0.5)) ; (TB, flip(0.2)) ; (Other, flip(0.01)))=true,true,false), add_all([ ["LungCancer",LungCancer], ["TB",TB], ["StomachFlu",StomachFlu], ["Cold",Cold], ["Other",Other], ["Cough",Cough], ["Fever",Fever], ["ChestPain",ChestPain], ["ShortnessOfBeath",ShortnessOfBeath]]).