# Distribution of combination of events with different distributions themselves

I am asked to find the PMF of $X$, for the following definition of $X$:

"There are two coins, one with probability $p_1$ of Heads and the other with probability $p_2$ of Heads. One of the coins is randomly chosen (with equal probabilities for the two coins). It is then flipped $n \geq 2$ times. Let $X$ be the number of times it lands Heads."

My intuition is that to choose the coin at random, there is first a Bernoulli distribution $Y \sim \operatorname{Bern} \left({\frac{1}{2}}\right)$, which has a simple PMF, namely $P(Y=1)=P(Y=0)=\frac{1}{2}$. Then once the coin is chosen there is some binomial distribution $X \sim \operatorname{Bin} \left({n},p_i\right)$ where the PMF is $P_i(X=k)=\binom{n}{k}p_i^k(1-p_i)^{n-k}$ for $i=1,2$.

I am confused as to how to combine these two distributions/PMFs together into one. I am also wondering what the distribution of $X$ would be if $p_1=p_2$; would it just be another binomial distribution?

## 1 Answer

meow234. The basic tools that we have for thinking about multiple random variables together are the joing distributions and conditional distributions. When we want to go from thinking about multiple variables at once to fewer variables we need to marginalize to obtain marginal distributions.

So as you point out in your question we have $Y \sim \mathcal{Ber}(0.5)$. (I'm going to use $p_0, p_1$ for ease of notation). Then given $Y$ we know how to draw $X$, so we have a conditional distribution, $X|Y \sim \mathcal{Bin}(n, p_{Y})$.

We can then compute the PMF for the joint distribution of $X,Y$ by taking the product:

$$P(X=x,Y=y) = P(X=x|Y=y)\cdot P(Y=y).$$

At the end of the day, what we're interested in though is $P(X)$. This requires that we marginalize the joint distribution by summing over all (both) possible values of $Y$.

$$P(X=x) = P(X=x|Y=0)\cdot P(Y=0) + P(X=x|Y=1)\cdot P(Y=1).$$

Why don't you see how far that gets you, and let me know if you have any questions by commenting on this answer.