Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For the density function below, I need to find $E(X)$ and $E(X^2)$. For $E(X)$, I did the following steps and got the answer of $-2/\sqrt{2\pi}$. However, this is incorrect as the correct answer is $\sqrt{\frac{2}{\pi}}$. I am unsure what I did incorrectly. For $E(X^2)$, is there any easier way to do it than by integration by parts? Thanks for the help.

Also, I tried a different approach that didn't work at all and I was wondering why it was incorrect. I split it up into two standard normals by adding them. Then, I used the theorem that the sum of two normals is also normal with a mean that is the sum of the two original normals and a variance that is a sum of the variances of the original normals. Going by that logic, I should get a normal with a mean of $0$ and a variance of $2$; however, that is obviously incorrect, so I am just wondering why.

$$ f(x) = \frac{2}{\sqrt{2\pi}} e^{-\frac{x^2}{2}} dx, \ \ \ \ \ 0 < x < \infty $$ $$ E(X) = \frac{2}{\sqrt{2\pi}} \int_0^\infty x e^{-\frac{x^2}{2}} dx. $$ Let $u = \frac{x^2}{2}$. $$ = - \frac{2}{\sqrt{2\pi}}. $$

share|cite|improve this question
But it does not show how you arrived at the negative answer. – Sasha Sep 26 '11 at 0:18
e^-u from 0 to infinite is -1 – icobes Sep 26 '11 at 0:22
Thank you! I forgot the negative that preceded e^-u when integrating. Much appreciated. – icobes Sep 26 '11 at 0:28
This is the half-normal distribution. Note $2/\sqrt{2 \pi} = \sqrt{2/\pi}$. – Henry Sep 26 '11 at 0:32
BTW, this is actually about the expectation of the absolute value of a normally distributed random variable. – Michael Hardy Sep 26 '11 at 0:35
up vote 1 down vote accepted

Since you got a negative answer, my first suspicion is that you didn't deal carefully with the bounds of integration. If $u=-x^2/2$, then as $x$ goes from $0$ to $\infty$, $u$ goes from $0$ to $-\infty$. Since $du=-x\;dx$, the integral $\int_0^\infty$ becomres $$\int_0^{-\infty} -e^u\;du.$$ So think about how to change that to $\int_{-\infty}^0\cdots\cdots$.

Also, it wouldn't hurt to recall a bit of algebra in order to understand the relationship between $\dfrac{2}{\sqrt{2\pi\;{}}}$ and $\dfrac{\sqrt{2}}{\sqrt{\pi}}$.

share|cite|improve this answer

There is absolutely no way you can obtain a negative answer, since $x>0$ and $f(x)$ is always positive, since it is a pdf. Integration has to go along the following lines:

$\varphi(x) = \int_{0}^{\infty}x e^{-\frac{x^2}{2}}dx = \int_{0}^{\infty}e^{-\frac{x^2}{2}}d(\frac{x^2}{2}) =\int_{0}^{\infty}e^{-t}dt=-[e^{-\frac{x^2}{2}}] \vert^{\infty}_{0}=1$

share|cite|improve this answer
I don't understand the notation on the left-hand side. What is $\varphi(x)$ supposed to denote and why is it a function of $x$? – cardinal Sep 26 '11 at 1:52
it's the integral in OP's question – sigma.z.1980 Sep 26 '11 at 3:16
sigma, please read carefully @cardinal comment, you cannot have some $x$ in $\varphi$ and in the integral (besides, you did not define $\varphi$). – Did Sep 26 '11 at 5:43
from OP, $EX=\frac{2}{\sqrt{2 \pi}} \varphi(x)$ – sigma.z.1980 Sep 27 '11 at 6:05
Sorry, but your last comment does not make sense either. $\mathbb E X$ is a number, not a function of $x$, and $\varphi$ is not found anywhere in the question, as far as I can tell. :) – cardinal Sep 27 '11 at 16:32

For calculating $E[X^2]$, you need not do integration by parts.

HINT Suppose $Y$ is distributed according to the standard normal $N(0,1)$. Do you know how to calculate $E[Y^2]$ (given its mean and variance)?

Secondly, the random variables $X^2$ and $Y^2$ are identically distributed. Can you see why? How would this fact help us?

share|cite|improve this answer
Are they identically distributed because X^2 is an even function? – icobes Sep 26 '11 at 0:52
@Srivatsan, I temporarily submitted a comment to the question, explaining basically your point here. Sorry about that, it seems that I somehow missed your answer. Comment now deleted. – Did Sep 26 '11 at 2:54
No problem @Didier. :) – Srivatsan Sep 26 '11 at 3:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.