Expected number of virus cells I've found this question in a past programming assignment from a course I'm currently reading.
Its statement looks like this :

A recent lab accident resulted in the creation of an extremely dangerous virus that replicates so rapidly it's hard to predict exactly how many cells it will contain after a given period of time. However, a lab technician made the following observations about its growth per millisecond:
$\bullet$ The probability of the number of virus cells growing by a factor of $a$ is $0.5$
$\bullet$ The probability of the number of virus cells growing by a factor of $b$ is $0.5$
Given a, b, and knowing that initially there is only a single cell of virus, calculate the expected number of virus cells after $t$ milliseconds. As this number can be very large, print your answer modulo $(10^9 + 7)$ .

As I have no prior training in probability or combinatorics, this problem doesn't make much sense to me . I've done some searching about expected values in the context of probability, but I can't see how to model the data I'm given. Perhaps there's something very obvious I'm missing, but I'm not able to see it at the moment.
How would you solve this?
 A: This was an interesting problem, but I think I have a solution:


*

*At time $t=0$ there is definitely just one virus cell, nothing to argue about here.

*At time $t=1$ there are $a$ cells with probability 1/2, and $b$ cells with prob. 1/2. The average is then $(a+b)/2$.

*At time $t=2$ there are $aa$ cells with prob. 1/4, $bb$ cells with prob. 1/4 and $ab=ba$ cells with prob. $1/4+1/4=1/2$. Average: (aa+bb+2ab)/4

*Et cetera...


What's the pattern? To generate all possibilities of the next generation of cells, we take the possible strings of a's and b's from the previous gen in two copies, concatenate an $a$ to one set of copies and a $b$ to the others. We multiply the probability of each old string by 1/2 to keep the expectation in check, and add things up.
But we don't have to generate actual strings!! (This is good, it avoids exponential blow-up). All we have to do, is take the average of the previous generation, divide by 2, and multiply by $(a+b)$, and we're good to go.
So...we just compute $(\frac{a+b}{2})^{t} \mod (10^9+7)$, and this is efficiently done (like $O(\log t)$ time) using repeated squaring. Just be careful of integer overflow, and you're done :)
(Feel free to ask for more details if necessary, I'm writing this in the middle of the night where I live…the above may not be as clearly written as I would like it to be)
A: Let $X$ be the number of times the "virus cell" population grew by factor $a$ in the $t$ milliseconds. 
Thus the population of 1, after $X$ growths of factor $a$ and $t-X$ growths of factor $b$ will be: $$\begin{align}N_t =&~ a^X b^{t-X} \\ = &~ b^t (a/b)^{X} \end{align}$$
Now, as $X$ is is the count of 'successes' in a series of $t$ independent Bernoulli trials with success rate $0.5$, it will have a Binomial Distribution.   $X\sim\mathcal {Bin}(t, 0.5)$
Now can you find this?  $~\mathsf E(N_t)$

Hint: A useful research topic is "moment generating functions".

 If $X\sim \mathcal{Bin}(n,p)$ then $\mathsf E(\mathsf e^{sX}) = (1-p+p\mathsf e^{s})^n$.   This is the moment generating function for a Binomial Distribution.

