# Generating function for an Arithmetic mean

I want to find out, how many ways I can produce an average 4.6 of 13 numbers, when I have only numbers {1,2,3,4,5}.

I thought, that it could be done by generating functions, but since my knowledge on them isn't very deep yet, I'm a little lost. Also I have a hard time dealing with the average not being integer.

-
If the average of $13$ numbers is $4.6$, then their sum must be $13 \times 4.6 = 59.8$, which isn't possible if the numbers are integers. Are you really looking to count how many ways you can produce an average of at least $4.6$? – mjqxxxx Jan 24 '11 at 21:43
My apologies, I didn't realize this might not be valid problem. While browsing, i found an image, rated 4.6 and there were only choices from 1 to five and 13 people had rated, so this excercise came from that. The difference would of course be rounding mistake. Can you help me define the problem better? – Ondrej Sotolar Jan 24 '11 at 21:56

13 numbers with average 4.6 would need to add up to 59.8; so you can't get that by choosing from the set of integers ${1,2,3,4,5}$. If you had solvable instance of this problem, for instance, 15 numbers with an average of 4.6, you would then be asking for the number of ways of choosing 15 numbers from ${1,2,3,4,5}$ with a sum of 69. A question like that can be answered by looking at the generating function $$F(x,t)\equiv\frac{1}{(1-tx)(1-tx^2)(1-tx^3)(1-tx^4)(1-tx^5)}$$ where the coefficient of the term $t^{15}x^{69}$ would be the answer you are looking for: $${\rm{number \; of \; ways}} = \left. \frac{1}{15!69!} \frac{\partial^{84} F}{\partial x^{69} \partial t^{15}}\right|_{x=0,t=0}$$

-

If you are adding 13 numbers and the average is $4.6$, this is equivalent to their sum being $4.6\times 13$. Unfortunately, that gives $59.8$, which is impossible to achieve if your original numbers were all integers. Which suggests (to me, at least) that you are in fact approximating the average, and that the actual average you want is $\frac{60}{13} = 4.615384615\ldots$

So, you want to know how many ways you can obtain $60$ as a sum of exactly $13$ integers, all taken from ${1,2,3,4,5}$. This is equivalent to counting the number of $5$-partitions of $60$ of length exactly $13$.

It can probably be done with generating functions, but here you can do it from first principles.

Note that the maximum sum you can possibly get with $13$ numbers taken from ${1,2,3,4,5}$ is $65$. So the partitions you want are in 1-to-1 correspondence with the partitions of $5$ other than the trivial one ($5=5$).

For instance, the partition $5=1+4$ gives the partition $60 = 11(5) + 4 + 1$ (subtract $1$ from one summand, $4$ from another summand). The partition $5=2+3$ yields the partition $60=11(5) + 3 + 2$. Etc. So you have: \begin{align*} 5 &= 1+4 &\qquad 60 &= 11(5) + 4 + 1;\\ 5 &= 2+3 &\qquad 60 &= 11(5) + 3 + 2;\\ 5 &= 1+1+3 &\qquad 60 &= 10(5) + 4 + 4 + 2;\\ 5 &= 1+2+2 &\qquad 60 &= 10(5) + 4 + 3 + 3;\\ 5 &= 1+1+1+2 &\qquad 60&= 9(5) + 4 + 4 + 4 + 3;\\ 5 &= 1+1+1+1+1 &\qquad 60&= 8(5) + 4 + 4 +4 + 4 + 4; \end{align*} where $60 = k(5) +\cdots$ means that you take the number $5$ $k$ times, and then the other numbers.

So there are exactly $6$ ways of doing it.

-

The mean, which is what we usually are talking about when we say average, is the sum of the numbers divided by how many there are. So the mean of 4 and 5 is (4+5)/2=4.5 Getting a fractional mean from integer numbers is no surprise, as in this case. However, the sum must have been an integer, so you cannot average 13 integers and get a mean of 4.6 because the sum would have to be 4.6*13=59.8 So either you have to be rounding or you have to accept sets smaller than 13. For example, you could have {4,4,5,5,5} with a total of 23 and a mean of 4.6

To do this with generating functions, you can observe that the only way to get a mean of 4.6 is with a sum of 23 and five numbers or a sum of 46 and 10 numbers. For 23 from 5 numbers in {1,2,3,4,5} the generating function is (x+x^2+x^3+x^4+x^5)^5 and take the coefficient of the x^23 term.

-