/* Four girls and one boy in Picat. From Statistics101 """ What is probability of selecting 4 girls and 1 boy, in any order, when selecting five students from any 25 girls and 25 boys? (From Page 122ff in "Resampling Stats: The New Statistics"). """ Exact probability: Picat> X=hypergeometric_dist_pdf(5, 25, 50, 4) X = 0.149261832392533 ChatGPT-o1-preview get the same result: https://chatgpt.com/share/66f3ad34-4d20-800b-a760-7f05c5f525fb """ Thought for 30 seconds ... Answer: An exact probability of 1375 divided by 9212, that is, probability = 1375⁄/9212 (~ 0.149261832392531) """ Cf my Gamble model gamble_four_girls_and_one_boy.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 : num girls Probabilities: 2: 0.3319000000000000 3: 0.3233000000000000 4: 0.1495000000000000 1: 0.1445000000000000 5: 0.0268000000000000 0: 0.0240000000000000 mean = 2.5102 var : p Probabilities: false: 0.8505000000000000 true: 0.1495000000000000 mean = [false = 0.8505,true = 0.1495] */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => N = 25, % N boys and N girls M = 5, % pick M children Children = ones(N,boy) ++ ones(N,girl), Selected = draw_without_replacement(M, Children), % How many girls? NumGirls = count_occurrences(girl,Selected), % 4 girls? P = check(NumGirls == 4), add("num girls",NumGirls), add("p",P). /* A simpler model var : num girls Probabilities: 3: 0.3260000000000000 2: 0.3070000000000000 1: 0.1690000000000000 4: 0.1490000000000000 0: 0.0300000000000000 5: 0.0190000000000000 mean = 2.452 var : p Probabilities: false: 0.8510000000000000 true: 0.1490000000000000 mean = [false = 0.851,true = 0.149] */ go2 ?=> reset_store, run_model(10_000,$model2,[show_probs_trunc,mean]), nl, % show_store_lengths,nl, % fail, nl. go2 => true. model2() => % 50 children. boys = 0, girls = 1 D = bern_n(1/2,50), % Pick 5. How many girls? NumGirls = take(D,5).sum, % 4 girls? P = check(NumGirls == 4), add("num girls",NumGirls), add("p",P).