# Expected value for a function with a normal distributed random variable

I have a random variable $$X \sim N(\mu, \sigma^2)$$ and a function $$5x^2 + 2x$$. How can I calculate $$E(g(x))$$ ?

I have two ideas, altough I'm not sure which one is right:

• $$E(g(x) = \int_{-\infty}^{\infty} g(x) f_X(x) dx\\ =\int_{-\infty}^{\infty} 5x^2 + 2x\frac{1}{\sigma\sqrt{2\pi}} e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2 }$$

• The function above just computes the weighted average of the values that $$g(x)$$ can take on for different values of x. The normal distrubution is symmetric, so $$E[g(x)] = 5 \mu^2 + 2\mu$$

Sorry if the question might sound stupid, I don't have a statistics background.

• Var(x) = E(x^2) - E(x)^2 Oct 19, 2019 at 14:31
• Expectation is 'linear': For constants $c,d$ and random variables $X,Y$, we have $E[cX+dY]=cE[X]+dE[Y]$ whenever all expectations exist.// Note that $E[X^2]$ does not equal $(E[X])^2$ for a non-constant variable $X$. Oct 19, 2019 at 16:30
• $\int_{-\infty}^{\infty} 5x^2 + 2x\frac{1}{\sigma\sqrt{2\pi}} e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2 }$ should be $\int_{-\infty}^{\infty} (5x^2 + 2x)\frac{1}{\sigma\sqrt{2\pi}} e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2 },$ which turns into two terms--one trivial and one requiring a bit of throught. // What does symmetry have to do with this? Oct 20, 2019 at 2:17

$$E[g(x)] = E[5x^2+2x] = 5E[x^2] + 2E[x]$$.

$$E[x^2] = var(x) + E(x)^2 = \sigma^{2} + \mu^{2}$$.

Hence $$E[g(x)] = 5(\sigma^2 + \mu^2) + 2\mu$$.

Read for Delta method for more general cases.

Edit) Sorry for the sign. For the $$E[x^2]$$, I changed the sign from (-) to (+) and henceforth.

When $$g(\cdot)$$ is not linear (for the $$N(\cdot, \cdot)$$, higher order moments are "known", but for general cases they are not) or X is non-normal, then you may apply delta method in order to get distribution of $$g(x)$$.

• What 'Delta method' in this context? Oct 19, 2019 at 16:23
• No, this is wrong (a $+$ sign has changed to a $-$ sign); cf. comment by @JesperHybel on main question. for the correct formula. Oct 19, 2019 at 16:31
• Right general idea. Checking results for a special case by simulation. Oct 20, 2019 at 1:39

Comment: Checking by simulation, for the special case $$\mu = 25, \sigma = 3.$$

set.seed(2019)
mu = 25;  sg = 3
x = rnorm(10^7, mu, sg)

y = 5*x^2 + 2*x
> mean(y)
[1] 3220.226   # aprx answ
2*sd(y)/sqrt(10^7)
[1] 0.4798108  # 95% margin of simulation error

5*(sg^2 - mu^2) + 2*mu
[1] -3030      # doesn't match aprx answ
5*(sg^2 + mu^2) + 2*mu
[1] 3220       # seems to match aprx answ