Derivation (mean and variance of normal distribution)

Suppose $X \sim N(0,1)$. $$ \begin{align*} \expect(X) = \int_{\R} x \cdot \frac{1}{\sqrt{2\pi}} e^{-x^2/2} \, dx. \end{align*} $$ This is the integral of an odd function, but we have to check it is integrable first: $$ \begin{align*} \expect|X| &= 2\int_{0}^{\infty} x\cdot \frac{1}{\sqrt{2\pi}} e^{-x^2/2}\, dx \\ &= -\frac{2}{\sqrt{2\pi}} \left[e^{-x^2/2}\right]_{0}^{\infty} \\ &= \sqrt\frac{2}{\pi} < \infty. \end{align*} $$ Hence $$ \begin{align*} \expect(X) = 0. \end{align*} $$

And for variance, $$ \begin{align*} \op{var}(X) &= \expect(X^2) - \ub{\expect(X)^2}_{0} \\ &= \int_{\R} x^2 \frac{1}{\sqrt{2\pi}} e^{-x^2/2} \, dx \\ &= -\frac{1}{\sqrt{2\pi}} \int x \, d(e^{-x^2/2}) \\ &= \frac{1}{\sqrt{2\pi}}\left(\left[-x e^{-x^2/2}\right]_{-\infty}^{\infty} + \int_{\R} e^{-x^2/2} \, dx\right) \\ &= 1. \end{align*} $$

So for $X\sim N(\mu, \sigma^2)$, $X = \sigma Z + \mu$ where $Z\sim N(0,1)$, so $$ \begin{align*} \expect(X) = \mu, \quad \op{var}(X) = \sigma^2. \end{align*} $$