/* Winning gold medals in Picat. From https://www.reddit.com/r/Probability/comments/1e5lhgf/probability_problem_w_no_solution/ """ Probability Problem w/ no solution? The problem: "olympic athletes from the US and China are among those most likely to win a gold metal. For a random athlete from either of these two countries, you have the following information: the probability of winning a gold medal if they practiced at least five hours per day = 0.6 the probability of winning a gold meal if they practiced less than five hours per day = 0.3 if an american athlete wins a gold medal, what is the probability that they practiced at least five hours per day?" Select only one: 1/3, 2/5, 1/2, 3/5 I suspect that the problem as stated can't have exact answer but instead a possible range. But by doing the calculations and using Bayes, I think that the problem statement is totally wrong... """ We don't care about the country since it seems to be irrelevant. For this model, it depends on how many possible hours an athlete can train per day. Cf my Gamble model gamble_winning_gold_medals.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. main => go. /* maxHoursPerDay = 10 var : p Probabilities: true: 0.6644113667117727 false: 0.3355886332882274 mean = [true = 0.664411,false = 0.335589] var : practice time per day Probabilities: 9: 0.1423094271538115 7: 0.1368967072620658 8: 0.1305818673883627 5: 0.1290031574199368 6: 0.1256202074875959 0: 0.0746504285069914 4: 0.0683355886332882 3: 0.0667568786648624 1: 0.0645015787099684 2: 0.0613441587731168 mean = 5.34326 maxHoursPerDay = 20 var : p Probabilities: true: 0.8516104294478528 false: 0.1483895705521472 mean = [true = 0.85161,false = 0.14839] var : practice time per day Probabilities: 10: 0.0611579754601227 9: 0.0601993865030675 19: 0.0590490797546012 18: 0.0588573619631902 16: 0.0588573619631902 6: 0.0584739263803681 12: 0.0580904907975460 11: 0.0580904907975460 14: 0.0565567484662577 15: 0.0557898773006135 5: 0.0552147239263804 13: 0.0542561349693252 7: 0.0542561349693252 17: 0.0531058282208589 8: 0.0496549079754601 2: 0.0312500000000000 4: 0.0306748466257669 1: 0.0300996932515337 3: 0.0283742331288344 0: 0.0279907975460123 mean = 10.5537 maxHoursPerDay = 12 var : p Probabilities: true: 0.7276916631755341 false: 0.2723083368244659 mean = [true = 0.727692,false = 0.272308] var : practice time per day Probabilities: 10: 0.1068286552157520 11: 0.1059907834101382 9: 0.1057813154587348 8: 0.1041055718475073 6: 0.1032677000418936 5: 0.1011730205278592 7: 0.1005446166736489 2: 0.0561374109761207 1: 0.0561374109761207 3: 0.0540427314620863 4: 0.0532048596564726 0: 0.0527859237536657 mean = 6.39171 */ go ?=> member(MaxHoursPerDay,[10,20,12]), println(maxHoursPerDay=MaxHoursPerDay), reset_store, run_model(10_000,$model(MaxHoursPerDay),[show_probs,mean]), nl, % show_store_lengths, fail, nl. go => true. model(MaxHoursPerDay) => PracticeTimePerDay = random_integer(MaxHoursPerDay), % Using uniform dist - unsurprisingly - gives about the same result. % PracticeTimePerDay = uniform_dist(0,MaxHoursPerDay), GoldMedal = cases([[PracticeTimePerDay < 5, flip(0.3)], [PracticeTimePerDay >= 5, flip(0.6)]]), % """ % if an american athlete wins a gold medal, what is the probability % that they practiced at least five hours per day? % """ P = check(PracticeTimePerDay >= 5), observe(GoldMedal == true), if observed_ok then add("practice time per day",PracticeTimePerDay), % add("gold medal",GoldMedal), add("p",P) end.