/* Three children paradox in Picat. From https://ali.medium.com/3-probability-paradoxes-challenging-our-understanding-of-chance-01d950affc9b """ Let’s consider a family with three children and analyze the probability that all these children will be of the same gender. Intuitively, one might think that since the first two children are bound to be of the same gender, the odds of the third child being the same gender should be 1/2. However, a closer examination of the probability reveals a different story. If we represent girls by ‘G’ and boys by ‘B,’ there are eight possible combinations: BBB, BBG, BGB, GBB, BGG, GBG, GGB, and GGG. Out of these combinations, only BBB and GGG consist of all boys or all girls, respectively, meaning the actual probability of all three children being the same gender is 2/8 or 1/4, not 1/2, as initially assumed. """ Cf my Gamble model gamble_three_children.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 : children Probabilities: [girl,boy,boy]: 0.1279000000000000 [boy,boy,girl]: 0.1265000000000000 [boy,boy,boy]: 0.1259000000000000 [boy,girl,girl]: 0.1255000000000000 [girl,girl,girl]: 0.1252000000000000 [girl,girl,boy]: 0.1245000000000000 [girl,boy,girl]: 0.1226000000000000 [boy,girl,boy]: 0.1219000000000000 var : p Probabilities: false: 0.7489000000000000 true: 0.2511000000000000 mean = 0.2511 */ 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() => N = 3, Children = categorical_n([1/2,1/2],[boy,girl],N), P = check( Children.remove_dups.len == 1), add("children",Children), add("p",P).