Computing expected values of a random variable, where we only have the moment generating function This is problem 37 from chapter 4 of Bertsekas and Tsitsiklis's Introduction to Probability.
The problem appears to come down to a filling of $n$ bins with $k$ objects and asking for the expected number of filled bins.
I computed the expected value of $X_{1}$, the random variable that is 0 if the first bin is empty and 1 if the first bin has at least one ball.
The complement of this event is for all the balls to land in the remaining $n-1$ bins. So the probability of the complement event is $p = (\frac{n-1}{n})^k$, implying that:
$$P_{X_{1}} = 1 - \left(\frac{n-1}{n}\right)^{k}$$
By linearity of expectation, the expected number of filled bins is the above probability (also the expectation) times $n$. I think this is correct. I checked on a few examples, but I might have made a mistake here.
The problem I have is that $k$ is defined by a random variable, and I only have the moment generating function $M_{K}(s)$. The expected value should be given in terms of $M_{K}(\cdot)$.
From the moment generating function, I know that I can compute expected values of moments of $K$, e.g., $\mathbb{E}[K]$ and $\mathbb{E}[K^{2}]$, but I am at a loss on how to merge that with the expected number of filled bins determined above.
What's the right approach here?
 A: Let $X_i$ be the indicator variable for whether the $i$th bin is filled. Notice that the $X_i$'s are identically distributed. As you correctly point out, $X_i \sim Bern(p)$ with $p = 1 - \left( \frac{n-1}{n} \right)^k$. The expected number of bins filled is then given by $E(X_1 + \ldots + X_n)$. Can you take it from there?
A: You seek $\mathsf E(\sum_{i=1}^n X_i)$ where $X_i$ is the indicator that bin $i$ is not empty, when you have $n$ bins and a random number of balls, $K$, and knowing the moment generating function for that.
We might assume the indicators are identically distributed, and with $\mathsf E(X_1\mid K)=1-(1-1/n)^K$ by the reasoning you gave (that each ball selects a bin independently and without bias).
Combining this with the Linearity of Expectation, with the Law of Total Expectation (aka the Law of Iterated Expectation), as @jlammy suggested, we begin with:
$$\begin{align}\mathsf E({\textstyle\sum_{i=1}^n X_i}) &= n\,\mathsf E(X_1)\\ &= n\,\mathsf E(\mathsf E(X_1\mid K))\\[1ex] &=n\,\mathsf E(1-(1-1/n)^K)\\[1ex] &= n\,(1-\mathsf E((1-1/n)^K))\\[1ex]&~~\vdots\end{align}$$
