/* Duck Hunter problem in Picat. From Siegrist "Probability Mathematical Statisics and Stochastic Processes", page """ Suppose that there are 5 duck hunters, each a perfect shot. A flock of 10 ducks fly over, and each hunter selects one duck at random and shoots. Find each of the following: 1. The probability density function of the number of ducks that are killed. 2. The mean of the number of ducks that are killed. 3. The standard deviation of the number of ducks that are killed. """ Cf my Gamble model gamble_duck_hunter_problem.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 killed Probabilities: 4: 0.4984000000000000 5: 0.3056000000000000 3: 0.1836000000000000 2: 0.0122000000000000 1: 0.0002000000000000 mean = 4.097 variance = 0.530391 stdev = 0.728279 */ go ?=> reset_store, run_model(10_000,$model,[show_probs_trunc,mean,variance,stdev ]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => DuckHunters = 5, Ducks = 10, Shoots = random_integer1_n(Ducks,DuckHunters), NumKilled = Shoots.remove_dups.len, add("num killed",NumKilled).