A run is a maximal sequence of success in a sequence of Bernoulli trials. For example, in the sequence $S,S,S,F,S,S,F,F,S$ where $S$ is success and $F$ is failure there are three runs consisting of three successes, two successes and one success. Let $R$ denote the random variable on the set of sequence of $n$ independent bernoulli trials that counts the number of runs in the sequence. Find $\operatorname{E}[R]$.
[Hint: Show that $R$ is a summation of $I_j$ where $j$ goes form $1$ to $n$ and $I_j = 1$ if a run begins at the $j\text{th}$ Bernoulli trial and $0$ otherwise. Find $\operatorname{E}(I_1)$ and then $\operatorname{E}(I_j)$].
It's trivial that $R = I_1 + I_2 + \cdots + I_n$, why? because a sequence with $R$ runs must have $R$ positions where each run starts, if there are 3 runs, there must exist 3 positions in the sequence where each of them starts. For example the runs at S,S,S,F,S,S,F,F,S start at positions 1,5, and 8, meaning $I_1 = I_5 = I_8 = 1$, the rest of the $I_j$'s are zero. Obviously $P(R=n) = 0$ because for there to exist at least 2 runs, there must be failures in between, which means at least one $I_j = 0$. Now you can calculate the expectation of $R$ $$ E(R) = E(I_1 + I_2 + \cdots + I_n) = E(I_1) + E(I_2) + \cdots + E(I_n) $$ The problem has been reduced to finding the expected value of each $I_j$ and summing over all of them. You have two cases: