Intro to probability chapter 4 ex 31 A group of 50 people are comparing their birthdays (as usual, assume their birthdays are independent, are not February 29, etc.). Find the expected number of pairs of people with the same birthday, and the expected number of days in the year on which at least two of these people were born.
Solution: Creating an indicator r.v. for each pair of people, we have that the expected number of pairs of people with the same birthday is (50C2 . 1/365) by linearity. Now create an indicator r.v. for each day of the year, taking the value 1 if at least two of the people were born that day (and 0 otherwise). Then the expected number of days on which at least two people were born is 
365( 1 −(364/365)^50 − 50· (1/365) ·(364/365)^49)

Could some1 explain how we got the answer ?
 A: (a) Number all possible pairs of people $1,2,\ldots,\binom{50}{2}$ and for all $i$ in this range define the indicator random variable:
$$I_i =
\begin{cases}
1 & \text{if pair $i$ share a birthday} \\
0 & \text{otherwise.}
\end{cases}$$
If $X=\text{#pairs sharing a birthday}$, then $X=\sum_{i}I_i$ and so,
\begin{eqnarray*}
E(X) &=& \sum_{i=1}^{\binom{50}{2}} E(I_i) \qquad\qquad\qquad\qquad\text{by linearity of expectation} \\
&=& \sum_{i=1}^{\binom{50}{2}} P(\text{pair $i$ share a birthday}) \\
&=& \sum_{i=1}^{\binom{50}{2}} \dfrac{1}{365} \\
&=& \dfrac{\binom{50}{2}}{365}.
\end{eqnarray*}
(b) For $i=1,2,\ldots,365,\;$ define the indicator random variable:
$$I_i =
\begin{cases}
1 & \text{if day $i$ has at least $2$ birthdays} \\
0 & \text{otherwise.}
\end{cases}$$
If $X=\text{#days with at least $2$ birthdays}$, then $X=\sum_{i}I_i$ and so,
\begin{eqnarray*}
E(X) &=& \sum_{i=1}^{365} E(I_i) \qquad\qquad\qquad\qquad\text{by linearity of expectation} \\
&=& \sum_{i=1}^{365} P(\text{day $i$ has at least $2$ birthdays}) \\
&=& \sum_{i=1}^{365} \left(1 - P(\text{day $i$ has $0$ birthdays}) - P(\text{day $i$ has $1$ birthday})\right) \\
&=& \sum_{i=1}^{365} \left(1 - \binom{50}{0} \left(\dfrac{364}{365}\right)^{50} - \binom{50}{1} \left(\dfrac{364}{365}\right)^{49}\dfrac{1}{365}\right) \\
&=& 365 \left(1 - \left(\dfrac{364}{365}\right)^{50} - 50 \left(\dfrac{364}{365}\right)^{49}\dfrac{1}{365}\right).
\end{eqnarray*}
