What is the probability of the following event?

Let $X_1, X_2, X_3, X_4$ be independent Bernoulli random variables. Then \begin{align} Pr[X_i=1]=Pr[X_i=0]=1/2. \end{align} I want to compute the following probability \begin{align} Pr( X_1+X_2+X_3=2, X_2+X_4=1 ). \end{align} My solution: Suppose that $X_1+X_2+X_3=2$ and $X_2+X_4=1$. Then $(X_2, X_4)=(0,1)$ or $(1,0)$. The probabilities of $(X_2, X_4)=(0,1)$ and $(1,0)$ are both $1/2 \times 1/2 = 1/4$. If $(X_2, X_4)=(0,1)$, then $X_1+X_2+X_3=X_1+X_3=2$. Therefore $X_1 = X_3 =1$. This happens with probability $1/4$. If $(X_2, X_4)=(1,0)$, then $X_1+X_2+X_3=X_1+1+X_3=2$. Therefore $(X_1, X_3) \in \{(1,0), (0,1)\}$. This happens with probability $1/4$. Therefore \begin{align} Pr( X_1+X_2+X_3=2, X_2+X_4=1 ) = 1/16+2/16=3/16. \end{align} Is this correct? Thank you very much.

Let's verify your result by simulation using a Python script:

import numpy as np

N = 10**5 # number of trials

# list of N 4-ples (X1, X2, X3, X4)
XX = [np.random.randint(2, size=4) for n in np.arange(N)]

# list of trials outcomes
P = list(map(lambda X: (X+X+X==2)&(X+X==1), XX))

# average of successes
np.mean(P) # ~ 0.18772

Since $\frac{3}{16} \simeq 0.18772$ this confirms your result.

• thank you very much. Your codes are very helpful. Are these python codes?
– LJR
Aug 4 '18 at 13:20
• @LJR You're welcome! Yes they are! I'll edit the answer Aug 4 '18 at 13:21

Just add as a supplementary technique:

You may also try to use the law of total probability with conditioning on $X_2$, since only $X_2$ are in common of the two events, then make use of the independence:

\begin{align} &\Pr\{X_1 + X_2 + X_3 = 2, X_2 + X_4 = 1\} \\ =& \Pr\{X_1 + X_2 + X_3 = 2, X_2 + X_4 = 1|X_2 = 0\}\Pr\{X_2 = 0\} \\ &+ \Pr\{X_1 + X_2 + X_3 = 2, X_2 + X_4 = 1|X_2 = 1\}\Pr\{X_2 = 1\} \\ =& \Pr\{X_1 + X_3 = 2, X_4 = 1|X_2 = 0\}\Pr\{X_2 = 0\} \\ &+ \Pr\{X_1 + X_3 = 1, X_4 = 0|X_2 = 1\}\Pr\{X_2 = 1\} \\ =& \Pr\{X_1 + X_3 = 2\}\Pr\{X_4 = 1\}\Pr\{X_2 = 0\} + \\ &+ \Pr\{X_1 + X_3 = 1\}\Pr\{X_4 = 0\}\Pr\{X_2 = 1\} \\ =& \frac {1} {4}\times \frac {1} {2} \times \frac {1} {2} + \frac {1} {2} \times \frac {1} {2} \times \frac {1} {2} \\ =& \frac {3} {16} \end{align}

So essentially you have counted the cases, just like what you have did.

Yes, your solution is indeed correct!

Minor comment: In the last sentence before the final expression "this" is probably referred to each of the outcomes $(1, 0)$ and $(0, 1)$ rather than to the event $(X_1, X_3) \in \{ (1, 0), (0, 1) \}$.