/* The Coupon Collector's problem: Consider an experiment with K possible outcomes, where outcome i occurs with probability p_i. Let N be the number of trials needed so that at least c occurences have occured of each outcome. When c=1 and p_i = 1/n, this is the Coupon Collector's problem. */ public class CouponCollector { static int getNumDraws (int K) { int[] A = new int [K+1]; int numNotCollected = K; int numDraws = 0; while (numNotCollected > 0) { numDraws ++; int i = (int) UniformRandom.uniform (1, K); if (A[i] == 0) { // This coupon has not been collected. A[i] = 1; numNotCollected --; } } return numDraws; } // K=#genes or urns, m=#draws static double estimateExtremeProb (int K, int m, int numTrials) { int numSuccesses = 0; for (int i=0; i