I don't understand why $X = \sum_{i=1}^n X_i$ and $Y = \sum_{i=1}^n Y_i$ I was reading the solution to this problem and noticed it used $X = \sum_{i=1}^n X_i$ and $Y = \sum_{i=1}^n Y_i$. I think I understand all other parts except this one. Would you please explain why $X = \sum_{i=1}^n X_i$ and $Y = \sum_{i=1}^n Y_i$?

 A: $X_k$ and $Y_k$ are always either $0$ or $1$. $X_k=1$ precisely when the $k$-th die shows a $1$, and $Y_k=1$ precisely when the $k$-th die shows a $2$. When you sum the $X_k$’s, you add $1$ for each die that shows a $1$ and $0$ for each die that shows something else, so the total is simply the number of dice showing a $1$. Similarly, when you sum the $Y_k$’s, you add $1$ for each die that shows a $2$ and $0$ for each die that shows something else, so the total is simply the number of dice showing a $2$.
For example, suppose that $n=8$, and the $5$ dice show $1,3,1,2,6,4,2,2$; then $X_1=X_3=1$, and all of the other $X_k$ are $0$, while $Y_4=Y_7=Y_8=1$, and the other five $Y_k$ are all $0$. Thus, 
$$\begin{align*}
X&=X_1+X_2+X_3+X_4+X_5+X_6+X_7+X_8\\
&=1+0+1+0+0+0+0+0\\
&=2\;,
\end{align*}$$
which is indeed the number of dice showing a $1$, and
$$\begin{align*}
Y&=Y_1+Y_2+Y_3+Y_4+Y_5+Y_6+Y_7+Y_8\\
&=0+0+0+1+0+0+1+1\\
&=3\;,
\end{align*}$$
the number of dice showing a $2$.
A: Here $X$ is the number of $1$'s when you roll a fair die $n$ times.
Recall that the random variables $X_1, X_2, X_3, \dots, X_n$ were defined as follows. $X_1=1$ if we get a $1$ on the first roll, and $X_1=0$ otherwise.
$X_2=1$ if we get a $1$ on the second roll, and $X_2=0$ otherwise.
$X_3=1$ if we get a $1$ on the third roll, and $X_3=0$ otherwise.
In general, $X_i=1$ if we get a $1$ on the $i$-th roll, and $X_i=0$ otherwise.
Then 
$$X_1+X_2+X_3+\cdots+X_n$$
is the total number of times you got a $1$, so it is the number of $1$'s that you got. But $X$ is by definition the number of $1$'s ou got.
Every time you get a $1$ on the die you write down a $1$, every time you don't get a $1$, you write down a $0$. So the sum of the numbers you write down is just the total number of $1$'s that you rolled. 
Exactly the same idea works for $Y$. You write down a $1$ if you roll a $2$, and write down a $0$ if you don't roll a $2$. The sum of all the numbers you wrote down is the total number of $2$'s that you rolled. 
This trick of using what are called indicator random variables $X_i$ is useful in many calculations.  
