Given a multiset (set that allows duplicates) $S$ of random integers in a range, and a subset $T \subseteq S$, what is the probability distribution of the sum of $T$? More formally:
Given $A,C \in \mathbb{Z}^+$ construct $S$ using the following algorithm:
- Start with $S=\emptyset$
- Pick random $x \in [1,A]$
- Add $x$ to $S$
- If $|S| < C$ then go back to 2, otherwise output $S$
So $$S=\left\{x : x \in [1, A] \right\}$$
And let $$B = \sum_{x \in S}x$$
Fix some $k \in [1,C]$. What is
$$P = \text{Pr}\left[ \sum_{y \in T}y = a, a \in [1,B], T \subseteq S \mid |T|=k \right]$$
I'm not sure if my notation is correct here but what I want is the probability of the sum of a subset equaling some random number, given a fixed size of the subset. I want the pdf as a function of $a$ & $k$, something like $P(a,k)=...$
There are some edge cases that are easy to compute:
$$ \begin{align} T=S \implies & P=0 \text{ unless } a=B \\ |T|=1 \implies & P=\frac{1}{A} \space \forall a \in [1,A] \text{ and } P=0 \space \forall a > A \\ a=B \implies & P=1 \text{ if } T=S \text{ and } P=0 \text{ otherwise} \\ a=1 \implies & P=1 \text{ if } |T|=1 \text{ and } P=0 \text{ otherwise} \end{align} $$
From here I thought about looking at specific sizes of $T$ and counting. Example, consider the case where $|T|=2$. We have the equation $$x_1+x_2=a$$
- if $a=1$ then there are no possible ways to satisfy the equation because $x_i \ge 1$
- if $a=2$ then there is exactly 1 way to satisfy the equation: $x_1=x_2=1$
- if $a=3$ then there are 2 ways: $(x_1=1 \wedge x_2=2) \vee (x_1=2 \wedge x_2=1)$
- if $a=n$ where $n \in [2,A+1]$ then there are $n-1$ ways
- if $a=A+n$ where $n \in [2,A]$ then there are $A-n+1$ ways
- if $a \gt 2A$ then there are no ways
We can add up the total number of ways: $$ \begin{align} & \sum_{n=2}^{A+1} (n-1) + \sum_{n=2}^A (A+n-1) = A(2A-1) \end{align} $$
and then get probabilities:
$$ \begin{align} P(a,2)= \begin{cases} \frac{a}{A(2A-1)} &: a \in [2,A+1] \\ \frac{A-a+1}{A(2A-1)} &: a \in [A+2, 2A] \\ 0 &: \text{otherwise} \end{cases} \end{align} $$
But this doesn't seem entirely correct because what if $B<2A$? The values $B$ and $C$ have not been taken into account and I'm not sure how to do this.