So, let's say we have $n = 16$ elements, $e_i,\; i = 1, 2, ..., n\;$. Each element can have any value of the set $S = \{0, 1, 2, ..., 255\}$ (for example), independently of the other elements. We compute the average as $m = \sum e_i/ n$.
My question is: in how many different ways, $N(n, S, m)$, you can combine the different $k$ values of the $S$ set between the $n$ elements so that they give a specific average $m$?.
For example, with $n = 16$, $S = \{0, 1, 2, ..., 255\}$ (so $k = 256$) and $m = 0$, it should yield $N(n, S, m) = 1$ since there's only one possible way to have that average, and it is when $\{e_1 = 0, e_2 = 0, ..., e_{16} = 0\}$. The same can be said if $m = 255$, since only the configuration $\{e_1 = 255, e_2 = 255, ..., e_{16} = 255\}$ could yield that average, so $N(n, S, m) = 1$ again.
It is clear that for $m = 1/16$ we have $N(n, S, m) = n$ since we can get that average only by these different configurations $\{e_1 = 1, e_2 = 0, ..., e_{16} = 0\}, \{e_1 = 0, e_2 = 1, ..., e_{16} = 0\}, ..., \{e_1 = 0, e_2 = 0, ..., e_{16} = 1\}$.
But besides these examples the problem of finding $N$ for an arbitrary $m$ becomes incredibly complicated (at least for me). Just trying the case for $m = 1/8$, means we can have $16 = n$ different cases where one of the elements has a value of $2$ and the other are $0$, plus $120 = n(n-1)/2$ different cases where two different elements have a value of $1$ and the rest is $0$, so $N(n, S, m) = n+n(n-1)/2 = 136$. But what about $m = 3/16$ or larger? $m = 128$ for example?
My guess is that this has to do with understanding the "Stars and Bars theorems", since the problem can be stated as having a number $M = m\cdot n = \sum e_i$ by combining different summing integers $e_i$. The problem, is how can I limit the result with the set of values $S$, these elements can have?