# probability distribution function calculation

I have probability distribution function of $x$: $P(x)$, where $x\in[1,2,...N]$.

I also have the sum: $$S = \sum_{j=1}^Kx_j$$ where $K$ is unknown.

Given $S$, is it possible to calculate probability distribution function of $K$: $P(K)$?

In other words, the probability: $P(K = i|S)$?

Thank you.

-
No, it is not possible without assumptions concerning the joint distribution of the $x_i$ given $K$, as well as a prior distribution for $K$. – r.e.s. Nov 23 '11 at 18:07

Suppose $g(z) = \sum_{x=1}^N z^x \mathbb{P}(X=x)$ is the probability generating function of $x$. Then, assuming i.i.d. $x_j$, the probability generating function for the sum of $S_k = \sum_{j=1}^k x_j$ for a fixed is simply the power: $$g_{S_k}(z) = g(z)^k$$ The probability you seek: $$\mathbb{P}(K=i | S=m) = [z]^m g(z)^i = \binom{i}{j_1,j_2,\ldots,j_N} \mathbf{1}_{j_1+2j_2+\ldots+N j_N = m} \prod_{s=1}^N \left(\mathbb{P}(X=s)\right)^{j_s}$$
Example: Let's assume that $X$ follows $\mathrm{Bin}(N-1,p)$ distribution shifted by +1. Then $g(z) = z (1-p+p z)^{n-1}$. Therefore $g(z)^i = z^i \left( 1-p+ p z\right)^{i (n-1)}$. In this case: $$\mathbb{P}(K=i|S=m) = \binom{i(n-1)}{m-i} p^{m-i} (1-p)^{ i n - m} \mathbb{1}_{n \cdot i \ge m \ge i}$$