# binomial-Poisson/beta hierarchy

X|N,P ~ Binomial(N, P)

N ~ Poisson(11)

P ~ Beta(2,3)

What is the moment generating function for X?

-
What are your thoughts so far? – Mike Spivey Dec 4 '10 at 22:53
E[exp(tX)] = E[E[exp(tX)|N,P]]= E[(P*exp(t) + 1 - P)^N] = ? – student Dec 5 '10 at 1:58

You've got the right start by conditioning on $N$ and $P$ to get $E[e^{tX}] = E[(Pe^t + 1-P)^N]$. Now, evaluate the second expression via $$E[(Pe^t + 1-P)^N] = E[E[(Pe^t + 1-P)^N|P]].$$ Since $N$ is Poisson, you will be able to get a closed-form answer for the inner expectation. The only remaining variable will then be $P$. But since $P$ is beta with small integer parameters the outer expectation will involve an integral of a low-degree polynomial times an exponential. That can be evaluated via integration by parts.

(Update with more details, after comments below. This problem is more complicated than I had realized at first!)

Applying the calculations described above, we have, where $\lambda = 11$, $$E[(Pe^t + 1-P)^N|P] = e^{\lambda P(e^t-1)}.$$ Then $E[e^{\lambda P(e^t-1)}]$ must be done piecewise, depending on the value of $t$. If $t = 0$, we have $$E[e^{\lambda P(e^t-1)}] = E[1] = 1.$$ Otherwise, $E[e^{\lambda P(e^t-1)}]$ is a much more complicated expression with, as the OP indicates, $(e^t-1)^4$ in the denominator:

$$E[e^{\lambda P(e^t-1)}] = \frac{12 \left(6 - 6 e^{\lambda (e^t-1)} + 2 \lambda (2 + e^{\lambda (e^t-1)}) (e^t-1) + \lambda^2 (e^t-1)^2\right)}{\lambda^4 (e^t-1)^4}$$

Because the limit of this latter expression as $t \to 0$ is $1$, $E[e^{\lambda P(e^t-1)}]$ is still continuous at $0$, despite the fact that it has to be calculated piecewise. It also turns out to be differentiable at $t = 0$ as well, and so one can still find moments with it. For example, to find $E[X]$ we differentiate the expression for $E[e^{\lambda P(e^t-1)}]$, $t \neq 0$, once with respect to $t$ and then take the limit as $t \to 0$. This gives $E[X] = 4.4$, which is the same result one would obtain by calculating $E[X]$ directly.

Incidentally, a similar situation occurs with the continuous uniform distribution on $[a,b]$. Its mgf is, for $t \neq 0$, $$\frac{e^{tb}-e^{ta}}{t(b-a)}.$$ The moments can be found by successively differentiating this expression and then taking the limit as $t \to 0$ rather than by substituting $0$ for $t$. See, for example, MathWorld's article on the uniform distribution.

-
Ok, I got E[exp(11p(exp(t)-1))] = (a bunch of stuff) / (exp(t) - 1)^4. But I should be able to differentiate that and set t = 0 and get E[X], but the derivative is undefined at t = 0. What am I doing wrong? – student Dec 6 '10 at 1:42
@student: Are you really just after $E[X]$? If so, you don't need the moment-generating function for that. – Mike Spivey Dec 6 '10 at 2:19
No, I'm after the moment generating function. I was just trying to check my answer, and that didn't seem right to me. – student Dec 6 '10 at 2:49
@student: That's a good point. Let me update my answer. – Mike Spivey Dec 6 '10 at 4:33