Poisson distribution given Exponential Distribution I would need some help on the following problem:
We consider two random variables $X$ and $Y$.
We suppose that, given X=x, the conditional law of $Y$ is a Poisson distribution of parameter $x$.
$X$ follows an exponential distribution of parameter $\lambda >0$.
We are trying to find $E(Y)$ and $V(Y)$.
I'm using the total probability formula first to find the unconditional distribution of $Y$:
$ P(Y=n)=\int _{ 0 }^{ +\infty  }{ P(Y=n/X=x)P(X=x) } dx=\int _{ 0 }^{ +\infty  }{ { e }^{ -x }\frac { { x }^{ n } }{ n! } \times \lambda { e }^{ -\lambda x } } dx=\frac { \lambda  }{ n! } \int _{ 0 }^{ +\infty  }{ { { x }^{ n }e }^{ -(\lambda +1)x } } dx=\frac { \lambda  }{ n! } { e }^{ \lambda +1 }\int _{ 0 }^{ +\infty  }{ { { x }^{ n }e }^{ -x } } dx $
So,
$E(Y)=\frac { \lambda  }{ n! } { e }^{ -(\lambda +1) }\int _{ 0 }^{ +\infty  }{ { { x }^{ n+1 }e }^{ -x } } dx$
$E({ Y }^{ 2 })=\frac { \lambda  }{ n! } { e }^{ -(\lambda +1) }\int _{ 0 }^{ +\infty  }{ { { x }^{ n+2 }e }^{ -x } } dx $
$V(Y)=E({ Y }^{ 2 })-E(Y)^{ 2 }$
What I'm stuck with is the calculation of $\int _{ 0 }^{ +\infty  }{ { { x }^{ n+1 }e }^{ -x } } dx$ and $\int _{ 0 }^{ +\infty  }{ { { x }^{ n+2 }e }^{ -x } } dx$
because I'm supposed to get a simple result for $E(Y)$ and $V(Y)$.
Doing an integration by parts won't solve the expression very much I think.
Update:
Given the feedback from André Nicolas:
$
E(Y)=\frac { \lambda  }{ n! } { e }^{ \lambda +1 }\int _{ 0 }^{ +\infty  }{ { { x }^{ n+1 }e }^{ -x } } dx=\frac { \lambda  }{ n! } { e }^{ \lambda +1 }(n+1)!=\lambda { e }^{ \lambda +1 }(n+1) $
$ E({ Y }^{ 2 })=\frac { \lambda  }{ n! } { e }^{ \lambda +1 }\int _{ 0 }^{ +\infty  }{ { { x }^{ n+2 }e }^{ -x } } dx=\frac { \lambda  }{ n! } { e }^{ \lambda +1 }(n+2)!=\lambda { e }^{ (\lambda +1) }(n+1)(n+2) $
which does not match any expected answer.
2nd attempt: now with a change of variable:
$ w=(\lambda +1)x\rightarrow x=\frac { w }{ \lambda +1 } \rightarrow dw=(\lambda +1)dx\rightarrow dx=\frac { dw }{ \lambda +1 }  $
$E(Y)=\frac { \lambda  }{ n! } \int _{ 0 }^{ +\infty  }{ { { x }^{ n+1 }e }^{ -(\lambda +1)x } } dx=\frac { \lambda  }{ n! } \int _{ 0 }^{ +\infty  }{ { e }^{ -w } } { \left( \frac { w }{ \lambda +1 }  \right)  }^{ n+1 }\frac { dw }{ \lambda +1 } =\frac { \lambda  }{ n! } { \left( \frac { 1 }{ \lambda +1 }  \right)  }^{ n+2 }(n+1)!=n{ \left( \frac { 1 }{ \lambda +1 }  \right)  }^{ n+2 } $
Third attempt, following hints from Did and André:
$ P(Y=n)=\int _{ 0 }^{ +\infty  }{ P(Y=n/X=x)P(X=x) } dx=\int _{ 0 }^{ +\infty  }{ { e }^{ -x }\frac { { x }^{ n } }{ n! } \times \lambda { e }^{ -\lambda x } } dx=\frac { \lambda  }{ n! } \int _{ 0 }^{ +\infty  }{ { { x }^{ n }e }^{ -(\lambda +1)x } } dx=\frac { \lambda  }{ n! } { e }^{ \lambda +1 }\int _{ 0 }^{ +\infty  }{ { { x }^{ n }e }^{ -x } } dx=\frac { n!\lambda  }{ n! } { e }^{ \lambda +1 }=\lambda { e }^{ \lambda +1 } $
which does not depends on $n$, so strange.
and therefore:
$ E(Y)=\sum _{ n=0 }^{ \infty  }{ nP(Y=n) } =\sum _{ n=0 }^{ \infty  }{ n\lambda { e }^{ \lambda +1 } } =\lambda { e }^{ \lambda +1 }\sum _{ n=0 }^{ \infty  }{ n }  $
which does not converge, so must be wrong.
Fourth Attempt:
After getting the right $ P(Y=n)$ from André:
$ E(Y)=\sum _{ n=0 }^{ \infty  }{ nP(Y=n) } =\sum _{ n=0 }^{ \infty  }{ n\frac { \lambda  }{ (\lambda +1)^{ n+1 } }  } =\frac { \lambda  }{ (\lambda +1) } \sum _{ n=0 }^{ \infty  }{ n{ { (\frac { 1 }{ (\lambda +1) } ) } }^{ n } } =\frac { \lambda  }{ (\lambda +1) } \frac { \frac { 1 }{ (\lambda +1) }  }{ { \left( 1-\frac { 1 }{ (\lambda +1) }  \right)  }^{ 2 } } =\frac { \lambda  }{ { (\lambda +1) }^{ 2 } } \frac { 1 }{ { \left( \frac { \lambda  }{ (\lambda +1) }  \right)  }^{ 2 } } =\frac { \lambda  }{ { (\lambda +1) }^{ 2 } } \frac { { \left( \lambda +1 \right)  }^{ 2 } }{ { { \lambda  }^{ 2 } } } =\frac { 1 }{ \lambda  }  $
I used the following identity:
$\sum _{ k=0 }^{ \infty  }{ k{ x }^{ k } } =\frac { x }{ { (1-x) }^{ 2 } } $
 A: Use the formulas
$\mathbb{E}(Y) = \mathbb{E}(\mathbb{E}(Y|X))$,
$V(Y) = \mathbb{E}(V(Y|X)) + V(\mathbb{E}(Y|X))$
A: We have for positive integers $n$,
$$\int_0^\infty x^ne^{-x}\,dx=n!.$$
The calculation is not hard. One uses integration by parts to get a reduction formula.
Added: To simplify $\int_0^\infty x^n e^{-(\lambda+1)x}\,dx$, let $w=(\lambda+1)x$. Then $dx=\frac{1}{\lambda+1}\,dw$ and $x^n=\frac{1}{(\lambda+1)^n}w^n$. So we end up with
$\int_0^\infty \frac{1}{(\lambda+1)^{n+1}}w^ne^{-w}\,dw$. And now use the first part of the answer.
More Added: When the integration is done as described above, we find that
$$\Pr(Y=n)=\frac{\lambda}{(\lambda+1)^{n+1}}.$$
Thus $Y$ has a distribution which is one of the two kinds of geometric random variable, where say the probability of head is $\frac{\lambda}{\lambda+1}$, the probability of tail is $\frac{1}{\lambda+1}$, and $Y$ is the number of tails before the first head. It is easier to remember the related random variable $T$, which is the number of trials before the first head. The expectation of $T$ is the reciprocal of $\frac{\lambda}{\lambda+1}$, and for the expectation of $Y$ we subtract $1$.
Or else you can note that $E(Y)=\sum_{n=0}^\infty n \frac{\lambda}{(\lambda+1)^{n+1}}$. This is a close relative of $\sum_{n=1}^\infty nr^n$, for which you can find closed form formulas, on MSE and elsewhere.
For the variance, the easiest thing to do is to look up the variance of a geometric random variable. Or else compute $E(Y^2)$ or else, a little easier, $E(Y^2-Y)$.
A: One way to compute such integrals is by parametric differentiation: Let $f(t)=\int_0^\infty e^{-t x}\,dx.$ Calculate that integral, then evaluate the first few derivatives at $t=1$ in two different ways.
