Moment Generating Function of a squared Gaussian R.V.

moment-generating-functionsnormal distributionprobability distributionsprobability theorystatistics

I have a question to why the pdf has only an $x^2$ term and not an $x^4$ term in computing the MGF of the squared gaussian mgf:

$$E[e^{tX^2}]
= \int_{-\infty}^\infty e^{tx^2}\tfrac1{\sqrt{2\pi}}e^{-x^2/2}dx
= \tfrac1{\sqrt{2\pi}}\int_{-\infty}^\infty e^{-(1-2t)x^2/2}dx
= \tfrac1{\sqrt{1-2t}},$$

I needed to compute the chi squared expectation and variance and always came up with the wrong answer.
Now I found the solution, which goes through the same steps I did, but it has the x term squared and I'm completely at a loss why it's not $x^4$.

The reasoning I went to $x^4$ is that I just treated $x^2$ as a variable itself and plugged it into the standard normal pdf.
I am assuming my mistake lies here? Would you be kind enough to explain why though?

Thank you very much in advance!

Best Answer

This is how it works: if $X$ is a continuous random variable on $\mathbb{R}$ with density $f$, and $g$ is some measurable function, then $g(X)$ has expectation

$$ \mathbb{E}[g(X)] = \int_{\mathbb{R}}g(x)f(x)~\mathrm{d}x.$$ Here we apply this with $g(x):= e^{tx^2}$.