# Calculating Prediction Intervals/Binomial Distribution with varying probabilities

Embarrassingly simple question here and apologies if this is all over the web, I was lacking some of the vocab I needed to Google it.

Let's say I have a set of samples with varying probabilities for the same event (we'll use a baseball analogy here, as that seems to be common). I have nine batters who have batting averages of: [0.250, 0.340, 0.210, 0.220, 0.300, 0.230, 0.290, 0.180, 0.110].

What I want to know is if all of these batters go up once, what is the probability of 9 hits, what is the probability of 8 hits, 7 hits, etc...

How do I calculate this more generally? In my case, I have a mean and I have a bunch of probabilities, but I can't figure out how to create some kind of distribution from that.

Essentially what I'm wondering is how to calculate a binomial distribution when the different trials have different probabilities of success.

Unfortunately, there's no good way of calculating this explicitly. You'll need to sum over all possible ways to get $H$ hits. To find $P(H)$ abstractly, you are solving for the coefficient of $x^H$ in $\prod_{i=1}^n[p_ix+(1-p_i)]$, or equivalently if $[n]:=\{1,2,\cdots,n\}$,
$$P(H)=\sum_{S\subset [n], |S|=H}\left[\prod_{p\in S} p\right]\left[\prod_{q\in S^c}(1-q)\right]$$