We have a sack with $60$ balls.

From them $15$ balls are red, $15$ green, $15$ blue and $15$ yellow.

We take $30$ balls from the sack.

What's the expected number of balls of the color from which the most balls had been taken? And from the color from which the least balls had been taken?

Expressed in the notation I begun to solve this unsuccesfully:

Let $X_i$ be a random event for the number of balls taken of the color $i$.

I look for: $E[\max(X_1,X_2,X_3,X_4)]$ and $E[\min(X_1,X_2,X_3,X_4)]$

I got that $P(X_i=x)=\frac{\binom{15}{x}\binom{45}{30-x}}{\binom{60}{30}}$

  • $\begingroup$ A not so useful observation: the sum of the two expected values required is 15 $\endgroup$ Jul 15, 2015 at 14:47

2 Answers 2


The joint distribution of $\boldsymbol X = (X_1, X_2, X_3, X_4)$ that counts the number of balls drawn of each color, is multivariate hypergeometric: $$\Pr[\boldsymbol X = (x_1, x_2, x_3, x_4)] = \binom{60}{30}^{-1} \prod_{k=1}^4 \binom{15}{x_k}, \quad x_1 + x_2 + x_3 + x_4 = 30.$$ Thus the desired expectation is simply $$\operatorname{E}[\max \boldsymbol X] = \sum_{\boldsymbol x \in M} \max(\boldsymbol x) \Pr[\boldsymbol X = \boldsymbol x],$$ where $M$ is the set of all possible outcomes of $\boldsymbol X$. While this is a tedious sum to compute by hand, it is computable using Mathematica:

$$\operatorname{E}[\max \boldsymbol X] = \frac{280571657719508835}{29566145391215356} \approx 9.48963.$$ Similarly, $$\operatorname{E}[\min \boldsymbol X] = \frac{162920523148721505}{29566145391215356} \approx 5.51037.$$

By request, Mathematica code:

Explicit computation of the sum (I make no claims that it's the most elegant or efficient approach):

Total[ Max[#] (Times @@ Binomial[15, #]) & /@ Select[Append[#, 30 - Total[#]] & /@ Tuples[Range[16] - 1, 3], 0 <= Last[#] <= 15 &]] / Binomial[60, 30]

Using the built-in probability distribution:

Expectation[ Max[x1, x2, x3, x4], {x1, x2, x3, x4} \[Distributed] MultivariateHypergeometricDistribution[30, {15, 15, 15, 15}]]

And of course, altering either code to compute the expectation of the minimum is straightforward.

Minor modification and additions can easily generate a plot of the expectation as a function of the number of balls drawn. Depicted below is the expectation of the maximum. It turns out that the explicit calculation (first version) is quite a bit faster than using the built-in distribution for the range of parameters involved.

enter image description here

  • $\begingroup$ Very nice! Is it appropriate to show Mathematica code? $\endgroup$
    – BruceET
    Jul 15, 2015 at 17:38
  • $\begingroup$ Thanks for sharing the code. Perhaps worthwhile reflecting on how much the possible values change if one draws 32 instead of 30. $\endgroup$
    – BruceET
    Jul 15, 2015 at 17:51

Comment. This plot shows maximum and minimum values from a million runs of this experiment. Points are randomly 'jittered' $\pm 0.3$ to prevent massive 'overplotting'. A few very rare, but possible combinations of values at upper-left of the plot did not occur in this particular simulation. From computations, the respective expected values seem to be about 5.51 and 9.49; the modes are 6 and 9, medians 6 and 9.

The four $X_i$ of this problem are correlated, so some traditional approaches towards an analytic solution are not available for deriving distributions of the maximum and minimum. Maybe this plot will suggest possible methods of solution.

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .