The following problem arises in a particular machine learning problem:

Assume that we have $n$ independent Bernoulli random variables with parameters $p_i$, e.g. $n=5$ and the $p$ vector is $(0.2, 0.3, 0.7, 0.6, 0.3)$. All possible realizations of the random variables form the corners of the $\lbrace 0,1\rbrace^n$-hypercube. There is one corner with highest probability (let's call it $c_\text{max}$), for $p=(0.2, 0.3, 0.7, 0.6, 0.3)$ we have $c_\text{max} = (0, 0, 1, 1, 0)$. Every corner of the hypercube is thus associated with a probability, let's call it $P^*$.

I am interested in the random variable $Z: \lbrace0,1\rbrace^n\rightarrow\lbrace0,\dots,n\rbrace$ with $Z(c) = $ Hamming distance from $c$ to $c_\text{max}$. Thus, I want to know the probability mass of $P^*$ at distance $1, 2, \dots n$ from $c_\text{max}$.

Brute-force traversal of the hypercube corners is out of the question for the problem sizes I'm considering ($n > 100$). However, I was thinking that there might by a clever (recursive?) way of exploiting the fact that the probabilities of neighboring corners differ by only one multiplicative factor of $p_i$ or $(1-p_i)$.

Although I don't think that I'm the first to contemplate this problem, a standard literature search has not revealed anything usable. Any algorithm ideas or pointers to the literature are much appreciated.

Thanks, Stephan