# Thread: M(t) calculus - can you pls double check?

1. ## M(t) calculus - can you pls double check?

Hello...

Would someone please double check and see if I make mistakes in the calculus of this integral?

$\displaystyle M_X(t)=\int_0^\infty 2 \lambda x\ e^{-\lambda{x^2}+tx} dx\$

The exponent can be rewritten as:

$\displaystyle -\lambda{(x-\frac{t}{2\lambda})^2}+\lambda{(\frac{t}{2\lambda} )^2}$ Therefore:

$\displaystyle M_X(t)=e^{\lambda{(\frac{t}{2\lambda})^2}}\int_0^\ infty 2 \lambda x\ e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx\ =\ e^{\lambda{(\frac{t}{2\lambda})^2}}\int_0^\infty 2 \lambda (x-\frac{t}{2\lambda}+\frac{t}{2\lambda})\ e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx\ =\\$

$\displaystyle =\ e^{\lambda{(\frac{t}{2\lambda})^2}}[\int_0^\infty 2 \lambda (x-\frac{t}{2\lambda})\ e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx\ +\ t\int_0^\infty e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx]\ =\\$

$\displaystyle =\ e^{\lambda{(\frac{t}{2\lambda})^2}}[-e^{-\lambda{(x-\frac{t}{2\lambda})^2}}\mid_0^\infty\ +\ t\int_0^\infty e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx]\ =\\$

I now convert the last remaining integral into normal gaussian of area 1/2 between zero and infinity:

$\displaystyle \mu=\frac{t}{2\lambda}\ ;\ \sigma^2=\frac{1}{2\lambda} \Rightarrow\ \ t\frac{\sigma\sqrt{2\pi}}{\sigma\sqrt{2\pi}}\int_0 ^\infty e^{-\frac{(x-\mu)^2}{2\sigma^2}}dx\ =\ \frac{t\sigma\sqrt{2\pi}}{2}\ =\ \mu\sqrt{\lambda\pi}\ ]$

Therefore, substituting:

$\displaystyle M_X(t)=e^{\lambda\mu^2}[-e^{-\lambda{(x-\mu)^2}}\mid_0^\infty +\mu\sqrt{\lambda\pi}\ ] = e^{\lambda\mu^2}[e^{-\lambda{\mu^2}} +\mu\sqrt{\lambda\pi}\ ] = 1+\mu\sqrt{\lambda\pi}e^{\lambda\mu^2}$

2. Originally Posted by paolopiace
Hello...

Would someone please double check and see if I make mistakes in the calculus of this integral?

$\displaystyle M_X(t)=\int_0^\infty 2 \lambda x\ e^{-\lambda{x^2}+tx} dx\$

The exponent can be rewritten as:

$\displaystyle -\lambda{(x-\frac{t}{2\lambda})^2}+\lambda{(\frac{t}{2\lambda} )^2}$ Therefore:

$\displaystyle M_X(t)=e^{\lambda{(\frac{t}{2\lambda})^2}}\int_0^\ infty 2 \lambda x\ e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx\ =\ e^{\lambda{(\frac{t}{2\lambda})^2}}\int_0^\infty 2 \lambda (x-\frac{t}{2\lambda}+\frac{t}{2\lambda})\ e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx\ =\\$

$\displaystyle =\ e^{\lambda{(\frac{t}{2\lambda})^2}}[\int_0^\infty 2 \lambda (x-\frac{t}{2\lambda})\ e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx\ +\ t\int_0^\infty e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx]\ =\\$

$\displaystyle =\ e^{\lambda{(\frac{t}{2\lambda})^2}}[-e^{-\lambda{(x-\frac{t}{2\lambda})^2}}\mid_0^\infty\ +\ t\int_0^\infty e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx]\ =\\$

I now convert the last remaining integral into normal gaussian of area 1/2 between zero and infinity: Mr F says: This is your mistake. When the Gaussian has a mean of $\displaystyle \mu$, the area is 1/2 between $\displaystyle \mu$ and infinity. Only if the mean is equal to zero will what you've got here be true.

$\displaystyle \mu=\frac{t}{2\lambda}\ ;\ \sigma^2=\frac{1}{2\lambda} \Rightarrow\ \ t\frac{\sigma\sqrt{2\pi}}{\sigma\sqrt{2\pi}}\int_0 ^\infty e^{-\frac{(x-\mu)^2}{2\sigma^2}}dx\ =\ \frac{t\sigma\sqrt{2\pi}}{2}\ =\ \mu\sqrt{\lambda\pi}\ ]$

Therefore, substituting:

$\displaystyle M_X(t)=e^{\lambda\mu^2}[-e^{-\lambda{(x-\mu)^2}}\mid_0^\infty +\mu\sqrt{\lambda\pi}\ ] = e^{\lambda\mu^2}[e^{-\lambda{\mu^2}} +\mu\sqrt{\lambda\pi}\ ] = 1+\mu\sqrt{\lambda\pi}e^{\lambda\mu^2}$
..

3. ## Mr. F, Thanks...

... believe it or not, this error came to my brain tonight. Problem is that if I make mu=0, the starting point of the integral changes and that area cannot be calculated analytically (or... can it?).

It seems this problem is not resolvable with regular analytical tools.

Mr.F, what do you suggest?

4. Originally Posted by paolopiace
... believe it or not, this error came to my brain tonight. Problem is that if I make mu=0, the starting point of the integral changes and that area cannot be calculated analytically (or... can it?).

It seems this problem is not resolvable with regular analytical tools.

Mr.F, what do you suggest?
When an integral does not have a known closed form what we do is invent
a new function who's derivative is the integrand.

$\displaystyle \int_0^\infty e^{-\lambda{(x-\frac{t}{2\lambda})^2}} dx = \lambda^{-1/2}\ {\rm{erfc}}\left(-\frac{t}{2 \sqrt(\lambda)}\right)$
$\displaystyle =\lambda^{-1/2}\left[1-{\rm{erf}}\left(-\frac{t}{2 \sqrt(\lambda)}\right)\right]$

In this case you need the error function $\displaystyle {\rm{erf}}(x)$, or the complementary error function $\displaystyle {\rm{erfc}}(x)$,