# Reasoning through the number of possible averages in a combination of numbers

I am working out a basic counting problem as follows.

Suppose I have five buckets and can choose a number from 1 to 5 from each bucket.

What is the probability that the average of my choices will be:

greater than 3, equal to 3, or less than 3?

I believe that it has to do with counting the number of ways to add five integers from 1 to 5 up to each of 1, 10, 15, 20, 25, but I don't feel that I'm reasoning about this in a principled way.

• I realise that I mis-stated the question, originally it was "six buckets with 1-5 from each bucket." I've changed it to 5 buckets choosing 1-5 since that is what most of the answers used. – Irwin Mar 7 '13 at 6:33

The probability of an average less than $3$ is equal to the probability of an average greater than $3$: if a given combination of numbers has average $a$, replacing each number $k$ by $6-k$ changes the average to $6-a$. Thus, it suffices to calculate the probability of getting an average of $3$: the other two probabilities are easily derived from it. That happens if and only if the sum is $15$.

The number of solutions to $x_1+x_2+x_3+x_4+x_5=15$ in positive integers is the same as the number of solutions to $y_1+y_2+y_3+y_4+y_5=10$ in non-negative integers, which is $$\binom{10+5-1}{5-1}=\binom{14}4\;;\tag{1}$$ see here if you’re not familiar with this ‘stars-and-bars’ calculation.

However, this includes solutions with one or more $x_k>5$ (or, equivalently, one or more $y_k>4$); you’ll need to use the inclusion-exclusion principle to eliminate them from the total. By another stars-and-bars calculation there are $\binom94$ solutions with $x_1>5$, and similarly for each of $x_2,\dots,x_5$, so $(1)$ must be reduced by $5\binom94$. This reduction overcompensates, because it counts twice those solutions with two variables exceeding their upper bounds. There are $\binom52$ pairs of variables, and yet another stars-and-bars calculation shows that for each of them there are $\binom44$ solutions with those variables exceeding their upper bounds. It’s impossible for more than two variables to exceed their upper bounds, so the final total is

$$\binom{14}4-5\binom94+10\binom44=381$$

ways to draw the numbers to produce an average of $3$. From here it’s straightforward to calculate the desired probabilities.

• Do you have clarification for how you accurately reason out what you exclude using the inclusion-exclusion principle? It appears to me that you identify that there's ${9 \choose 4}$ elements because that reasons to $n=6$ and $k=4$, which corresponds to values of 6 and above placed into 4 bins; there's yet another reduction you mention. I can reason through why this needs to be removed when placed in front of me but I am wondering how I might reason through this for new problems. (Nonetheless, your solution is extremely helpful as well as correct). – Irwin Mar 7 '13 at 5:32
• @Irwin: I start with the number of unrestricted solutions. Then I subtract those that exceed one upper bound, add back in those that exceed two, subtract those that exceed three, and so on; that’s just the inclusion-exclusion principle. To count the number of solutions exceeding the upper bound on the first two variables, say, I first allot the upper bound, in this case $5$, to each of $x_1$ and $x_2$; that leaves me to count positive integer solutions to $x_1+x_2+x_3+x_4+x_5=5$, of which there are $\binom44$. (For some reason I originally wrote and used $binom64$, which is wrong.) – Brian M. Scott Mar 7 '13 at 5:41
• So in my head I've been adapting the given solutions to what I actually wanted to calculate, which is six questions that each have a choice of five numbers. This is a total of $5^6$ combinations. An average of 3 is a sum of 18, meaning that we calculate ${17 \choose 5} - 6{10 \choose 5} + {6 \choose 3} * 0$. Since no solutions where $n \ge 6$ exist to add up to five in the case where $k=6$, the last term is zero. – Irwin Mar 7 '13 at 7:03
• So to confirm... the number of instances an x (such as $x_1$) is greater than 5, i.e. $x_1 > 5$, is the same as counting instances where we have $n=5$ but $k=10$, i.e. $15-5=10$. We have five combinations of those (one for each $x_n$). But, we have to add back instances where they are counted twice (note to self: which instances are counted twice?). Thus we have to calculate the case where two variables are 5, meaning that we have $15 - 5\times2 = 5$ such that we calculate ${4 \choose 4}$. The number of ways to combine 2 variables into 5 slots is ${5 \choose 2} = 10$. – Irwin Mar 7 '13 at 20:49

Hint: The probability that the average is equal to 3, is the probability that 5 numbers subject to $1 \leq a, b, c, d, e \leq 5$ satisfies $a + b + c + d + e = 5$. You can count the number of ways using the Principle of Inclusion and Exclusion.Let this probability be $P$.

By symmetry, the probability that the average is greater than 3, is equal to the probability that the average is less than 3. You can also see this by doing the substitution $a = 6 - a'$. Thus, the probability of both of these cases is $\frac {1-P}{2}$.

Yet another way of arriving at the solution would be to use generating functions. The answer would to expand the series :

$(x + x^2 + x^3 + x^4 + x^5)^6$, or

$x^6(1 + x + x^2 + x^3 + x^4)^6$

Calculating the coefficients of $x^{18}$ would give the number of ways of getting a sum of 18 and thereby an average of 3.

The calculation of the coefficients are easier than it looks. The previous answer suffices and is rather simple, but generating functions are too honking fun!! Cheers!!

• The bar that you place as "simple" has confused me for the past three or so hours! I dread combinatorics and usually would do everything programatically. – Irwin Mar 7 '13 at 7:04
• If you dread combinatorics, then there's no doubt you will be having a hard time with this problem. Just imagine what we do here mathematically is just a algebraic automation of algorithmic computation. For anyone who is familiar with series expansions $(1 + x + x^2 + x^3 + x^4)^6$ takes few steps of algebra to compute (which involves geometric progression summations and infinite series expansions.I will re-edit and explain. But you have to go through a little math. Get a general idea of generating functions OR go through the links in the previous answer,they are very interesting and complete – Vigneshwaren Mar 7 '13 at 7:34
• I don't recommend you to start with generating functions though, I HIGHLY recommend you go through the 2 links in the previous answer, that's probably better at this stage for you. – Vigneshwaren Mar 7 '13 at 7:47