/* Coupon collector's problem in Picat. From ## https://www.maa.org/frank-morgans-math-chat-rolling-a-die-until-every-face-has-appeared https://sites.williams.edu/Morgan/math-chat-archives/rolling-a-die-until-every-face-has-appeared/ """ LD CHALLENGE (Steve Jabloner). How many times do you think you need to roll a normal die to be 90% sure that each of the six faces has appeared at least once? Why? ANSWER. It takes 23 rolls, as Al Zimmerman discovered in a computer experiment rolling 5000 dice until 90% of them had shown each face. In a less accurate experiment with just 300 dice, Eric Brahinsky wrongly concluded that 22 rolls provide a 90.7% probability. """ This is a port of my Gamble model gamble_coupon_collectors3.rkt Note: See ppl_geometric_cereal_box.pi for a more extensive test of the coupon collector's problem. 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. /* Here we just show the HPD interval of 90% var : v HPD intervals: HPD interval (0.9): 6.00000000000000..23.00000000000000 */ go ?=> reset_store, N = 6, % run_model(10_000,$model(Map,N),Map,[show_probs,mean]), % We don't show anything automatically run_model(10_000,$model(N),[]), show_hpd_intervals(get_store().get("v"),[0.90]), nl. go => true. model(N) => % From ppl_geometric_cereal_box.pi Vs = [ 1+geometric_dist(1 - (I / N)) : I in 0..N-1], add("v",Vs.sum).