/* Distinct six dice in Picat. From https://www.quora.com/What-are-the-most-interesting-or-popular-probability-puzzles-in-which-the-intuition-is-contrary-to-the-solution/answer/Justin-Rising """ I'm going to flip six standard dice, and count the number of distinct values that come up. So if the result is (6,5,1,2,4,6) I record a five, and if the result is (6,6,4,1,1,6) I record a three. What's the probability that I record a four? I guarantee that unless you've worked out this puzzle before, your first answer is going to be pretty far off. See the comments for the right answer. Answer: ... And our final answer (including the extra factor from the first paragraph) is: 65×(64)×4!66≈0.501543209876543 """ Cf my Gamble model gamble_distinct_six_dice.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. /* n = 6 var : num unique Probabilities: 4: 0.5001000000000000 3: 0.2363000000000000 5: 0.2295000000000000 2: 0.0183000000000000 6: 0.0157000000000000 1: 0.0001000000000000 mean = 3.9877 var : p Probabilities: true: 0.5001000000000000 false: 0.4999000000000000 mean = [true = 0.5001,false = 0.4999] n = 10 var : num unique Probabilities: 6: 0.3513000000000000 7: 0.3503000000000000 8: 0.1324000000000000 5: 0.1275000000000000 4: 0.0187000000000000 9: 0.0179000000000000 3: 0.0016000000000000 10: 0.0003000000000000 mean = 6.5003 var : p Probabilities: false: 0.9813000000000000 true: 0.0187000000000000 mean = [false = 0.9813,true = 0.0187] */ go ?=> member(N,[6,10]), println(n=N), reset_store, run_model(10_000,$model(N),[show_probs_trunc,mean]), nl, % show_store_lengths,nl, fail, nl. go => true. model(N) => X = random_integer1_n(N,N), NumUnique = X.remove_dups.len, P = check(NumUnique == 4), add("num unique",NumUnique), add("p",P).