Conditional distribution of sum of binomial variables given the number of variables with non-zero values Let $T$ be a set of $M$ sets of size $(N / M)$ whose values are restricted to $\{0, 1\}$ where $M \leq N$ and $N \equiv 0 \pmod{M}.$
Each value is either $0$ or $1$ with some probability p
Let $F(T)$ be the number of sets in $T$ whose subsets contain one or more entries of $1$.
Let $G(T)$ be the sum of values over every set in $T$. 
Given $M$, $N$, and $F(T)$, but without knowing the exact contents of $T$, what is the probability distribution for $G(T)$ ? 
ex. With all values known:
$$p = 0.5$$
$$N = 6$$
$$M = 3$$
$$T = \{\{0, 0\}, \{1, 1\}, \{0, 1\}\}$$
$$F(T) = 2 $$
$$G(T) = 3$$
What I want to solve for:
$$p = 0.5$$
$$N = 6$$
$$M = 3$$
$$T = \ ???$$
$$F(T) = 2$$ 
What is the probability that $G(T) = X$ where $0 \leq X \leq N$ ?  
 A: To recapitulate (and put the notation in a form I can easily work with),
we suppose we have a list of $N = mk$ iid Bernoulli variables,
$$T=(X_{11},X_{12},\ldots,X_{1k},X_{21},X_{22},\ldots,X_{2k},
   \ \ldots,\ X_{m1},X_{m2},\ldots,X_{mk}),$$
that is, variables $X_{ij}$ where $1\leq i\leq m$ and $1\leq j\leq k$.
We let $p = P(X_{ij} = 1)$ and assume the values of $m$, $k$, and $p$ are known.
Let $Y_i = X_{i1} + X_{i2} + \cdots + X_{ik},$
so $Y_i$ is a binomial variable with parameters $k$ and $p$.
Using the notation $I_A$ for a quantity that is $1$ if $A$ is true and $0$ if $A$ is false,
we define
$$F(T) = \sum_{i=1}^m I_{Y_i > 0}
 \quad \mbox{and} \quad
 G(T) = \sum_{i=1}^m Y_i.$$
That is, $F(T)$ is the number of variables $Y_i$ such that at least one of the
Bernoulli variables $X_{i1},X_{i2},\ldots,X_{ik})$ is $1$,
and $G(T)$ is the total number of Bernoulli variables that have value $1$.
Given a particular value of $F(T),$ say, $F(T) = c,$ and given a value $x$,
we are to find the probability that $G(T) = x.$
That is, we want the conditional probability $P(G(T) = x \mid F(T) = c).$
This probability obeys the formula
$$ P(G(T) = x \mid F(T) = c) = \frac{P((G(T) = x) \cap (F(T) = c))}{P(F(T) = c)}.$$
So now we have merely the task of calculating the numerator and the denominator
on the right-hand side of that equation.
The denominator is simpler.
We have $P(Y_i = 0) = (1 - p)^k,$ so the variable $I_{Y_i > 0}$ is itself 
a Bernoulli variable with parameter $p_1 = 1 - (1 - p)^k.$
That means $F(T)$ has a binomial distribution and
$$P(F(T) = c) = \binom mc p_1^c (1 - p_1)^{m-c} 
   = \binom mc (1 - (1 - p)^k)^c (1 - p)^{n-ck}.$$
For the numerator, let's count the possible events.
There are $\binom mc$ different choices of which combination of $Y_i$ should be non-zero.
For each such choice of $c$ non-zero variables $Y_i$,
containing a total of $ck$ of the Bernoulli variables $X_{ij},$
exactly $x$ of those $ck$ variables take the value $1$ and the rest are all $0$.
The number of combinations of $x$ items selected from $ck$ items is $\binom{ck}{x}$.
But if we include all such combinations, unless $x$ is particularly close to $ck$
it is possible that one of the $Y_i$ that were supposed to be non-zero will
be zero because we failed to choose any of the $X_{ij}$ from which that $Y_i$
was constructed.
Therefore we need to exclude all cases where that happens. There are $c$ ways to
choose one of the $Y_i$ to be zero, and then there are $\binom{ck-k}{x}$
ways to select $x$ Bernoulli variables from among the remaining choices.
If we subtract all of these choices, we are left with
$$\binom{ck}{x} - c \;\binom{ck-k}{x}.$$
But consider the possibility that when we selected the $x$ Bernoulli variables,
two of the $Y_i$ were set to zero.
There are $\binom c2$ pairs of $Y_i$ for which this could happen,
and for each pair there are $\binom{ck-2k}{x}$ to select the $x$ variables
from those that are still available.
Each of those possibilities was deducted twice from the total count in the expression
above, so we have to add one of those possibilities back:
$$\binom{ck}{x} - c \;\binom{ck-k}{x} + \binom c2 \binom{ck-2k}{x}.$$
But now we have added back some cases where three of the $Y_i$ are zero.
Following the inclusion-exclusion principle, we subtract cases in which
three $Y_i$ are zero, add cases where four $Y_i$ are zero, and so forth,
until there fewer than $x$ Bernoulli variables to choose from among
the remaining non-zero $Y_i$, for a final total of
$$\binom{ck}{x} - c \;\binom{ck-k}{x} + \binom c2 \binom{ck-2k}{x}
- \binom c3 \binom{ck-3k}{x} + - \cdots$$
$$= \sum_{h=0}^{\lfloor c - x/k\rfloor} (-1)^h \binom ch \binom{ck-hk}{x}.$$
The closer $x$ is to $ck$, the fewer terms we actually have to compute.
Each one of the possibilities counted by that last sum is just a particular way
in which $x$ of the $n$ original Bernoulli variables have value $1$ and all
the rest have value $0$; the probability of one such combination of $x$ variables
is $p^x(1-p)^{n-x}.$ 
Moreover, the sum above counted only the possibilities for one of the $\binom mc$
choices of which of the $Y_i$ are non-zero.
Hence
$$P((G(T) = x) \cap (F(T) = c))
 = \binom mc p^x(1-p)^{n-x}
    \sum_{h=0}^{\lfloor c - x/k\rfloor} (-1)^h \binom ch \binom{ck-hk}{x}.$$
Plugging the values of $P((G(T) = x) \cap (F(T) = c))$ and $P(F(T) = c)$
into the equation for $P(G(T) = x \mid F(T) = c)$,
the factors of $\binom mc$ cancel, and
there will be some cancellation of a power of $(1-p)$ on the top and bottom,
but other than that I haven't found much that can be simplified.
It's definitely a computable quantity, however.
