<< DiscreteMath`Combinatorica`

 (* five pills 

Suppose you are taking one each of 5 different types of pills every day but you don' t like having to open and close 5 different bottles so at the beginning of each (30 - 
            day) month you put 30 of each type of pill into one big bottle .  
          When it is time to take your pills you draw them out of the big bottle one at a time until you have (at least) one of each type .  
          On the last day of the month you will draw exactly 5 pills and they will all be different because that' s all that' 
        s left in the bottle but on other days you will generally have to draw more than 5 pills in order to have (at least) one of each type .  
          So the question is

On the first day of each month when there are 150 pills (5 types x 30 pills/type )  in the bottle how many pills on average must you draw from the bottle in order to have at least one of each of the 5 types?

*) 

 (* 
      Given a set consisting of m disjoint subsets each of size n,  the number of subsets of size k which lack members from at least one of the m subsets is: *) 
lacksome[m_, n_, 
          k_]   := (∑_(j = 1)^m)(-1)^(j - 1) Binomial[
              m, j] Binomial[m n  -  j n, k];
 (* 
      The number of subsets of size k which include at least one member from each of the m subsets is: *) 

someofeach[m_, n_, k_]  :=  
        Binomial[(m n), k]  -  
          lacksome[m, n, k];

(* 
      the number of subsets of size k which lack members from only one of the m subsets *) 

lacksone[m_, n_, 
          k_]  :=   m someofeach[m - 1, n, 
            k] ;

 (* 
      What is the probability that exactly one of the m subsets is not represented in a subset of k ? *)

P[m_, n_, k_]  :=  
        lacksone[m, n, k]/
          Binomial[(m n), k];

Q[m_, n_, k_]   :=  
        P[m, n, k - 
              1] (n/(m n  -  k  +  
                  1));

L[m_, 
          n_]  :=  (∑_(k = 1)^(m n ))k*
            Q[m, n, k] ;

L[5, 30]

N[L[5, 30], 5]

10.954477520940673`

(* Copyright © 2000 - 
            2005 Michael A . Gottlieb .  
                All rights reserved. *)