Moment generating function from a $f(x)$

Given a function, I am required to find the $E[X]$ and $Var[X]$ without using MGF and then have to verify the answer by finding the MGF. I found the $E[X]$ and MGF. However, I am unable to verify whether the $E[X]$ is correct.

$$f(x) = \pi \frac{a^x}{(x!)}e^{-a}+ (1-\pi) \frac{b^x}{(x!)}e^{-b}$$

My solution:

MGF:

$$e \frac{a+b}{x+1}$$

E[X]:

$$\frac{a+b}{x}$$

How to I go about from here to show that my $E[X]$ is correct when verified using MGF and how do I find the $\mathrm{var}[x]$?

I know that the formula for finding the variance is

$$E[x-E[X]^2]$$

But I don't know how to apply this formula to find the $\mathrm{var}[x]$.

I am new to this concept so am facing difficulties. Any help or hints are appreciated. Thank you very much for your help.

• How did you derive $E[X]$ to be a function of x??? Something is wrong. – Alex R. Feb 15 '15 at 20:03

The key observation here is that the PMF $f(x) = \Pr[X = x]$ is a mixture of Poisson random variables with mixing weights $\pi$ and $1-\pi$; i.e., $$f(x) = \pi \Pr[X_a = x] + (1-\pi) \Pr[X_b = x],$$ where $X_a \sim \operatorname{Poisson}(a)$ and $X_b \sim \operatorname{Poisson}(b)$. Thus \begin{align*} \operatorname{E}[X^k] &= \sum_{x=0}^\infty x^k \Pr[X = x] \\ &= \sum_{x=0}^\infty x^k \left( \pi \Pr[X_a = x] + (1-\pi) \Pr[X_b = x] \right) \\ &= \pi \operatorname{E}[X_a^k] + (1-\pi) \operatorname{E}[X_b^k]. \end{align*} But since $X_a, X_b$ are individually Poisson, it is clear that \begin{align*} \operatorname{E}[X] &= \pi a + (1-\pi) b, \\ \operatorname{E}[X^2] &= \pi(a^2 + a) + (1-\pi)(b^2 + b). \end{align*} Therefore, $$\operatorname{Var}[X]= \left(\pi(a^2 + a) + (1-\pi)(b^2+b)\right) - (\pi a + (1-\pi) b)^2.$$ If we wish to derive the Poisson MGF, we can write $$M_Y(t) = \operatorname{E}[e^{tY}] = \sum_{y=0}^\infty e^{ty} e^{-\lambda} \frac{\lambda^y}{y!} = e^{(e^t-1)\lambda} \sum_{y=0}^\infty e^{-e^t \lambda} \frac{(e^t \lambda)^y}{y!} = e^{(e^t - 1)\lambda}.$$ Consequently it is not difficult to see that $$M_X(t) = \operatorname{E}[e^{tX}] = \pi M_{X_a}(t) + (1-\pi) M_{X_b}(t) = \pi e^{(e^t - 1)a} + (1-\pi)e^{(e^t - 1)b}.$$ Then $$\operatorname{E}[X] = \frac{d}{dt}\left[ M_X(t) \right]_{t=0} = \pi a e^{a(e^0 - 1) + 0} + (1-\pi) b e^{b(e^0 - 1) + 0} = \pi a + (1-\pi)b.$$ We also have \begin{align*} \operatorname{E}[X^2] &= \frac{d^2}{dt^2} \left[M_X(t)\right]_{t=0} \\ &= \pi a(1+a e^0)e^{a(e^0-1)+0} + (1-\pi) b(1+b e^0)e^{b(e^0-1)+0} \\ &= \pi a(1+a) + (1-\pi) b(1+b). \end{align*} These last two results clearly coincide with the above, thus the variance is also the same as that calculated above.

• Even if you don't use already known properties of the Poisson distribution, it is straightforward to begin from the PMF and derive the relevant properties, such as the mean and variance. We already derived the MGF as shown above, for example. – heropup Feb 16 '15 at 2:07

Your MGF is $M(t):=\sum_{x\geq 0}e^{tx}f(x)=\pi e^{-a} \exp(e^ta)+(1-\pi)e^{-b}\exp(e^tb)$.

$$E[X]=\left.\frac{d}{dt}M(t)\right|_{t=0}=a\pi +(1-\pi)b$$

The calculation of $E[X]$ using $\sum_{x\geq 0} xf(x)$ is similar because you need to calculate a sum of the form

$$\sum_{x\geq 0} \frac{xa^x}{x!}=\sum_{x>1} \frac{a^x}{(x-1)!}=a\exp(a),$$

which should get you the same answer.

For variance, remember that $E[(X-E[X])^2]=E[X^2]-E[X]^2$. You can use the MGF to figure out $E[X^2]$ by taking two derivatives and you already know $E[X]$.