# Expected Value

The expected value of r.v. $X$, usually written as $E\left(X\right)$, is defined as

$E\left(X\right)=\sum_{x\in\mathbf{R}}x\,f_{X}\left(x\right)$ if $X$ is discrete

$E\left(X\right)=\int_{-\infty}^{+\infty}t\,f_{X}\left(t\right)dt$ if $X$ is continuous

In general, suppose we would like to calculate $E\left(g\left(X\right)\right)$ where $g\left(\cdot\right)$ is a function. Then we would obtain

$E\left(g\left(X\right)\right)=\sum_{x\in\mathbf{R}}g\left(x\right)\,f_{X}\left(x\right)$ if $X$ is discrete

$E\left(g\left(X\right)\right)=\int_{-\infty}^{+\infty}g\left(t\right)\,f_{X}\left(t\right)dt$ if $X$ is continuous

## Existence of the Expected Value

Unlike in the discrete case, it is possible to obtain $E\left(X\right)=\infty$ in the continuous case. This is surprising if we think of expectations as averages, because no average of finite numbers turn out to be infinite. However, this is not assured in the case where $X$ is continuous. To see this, notice that we already know that some integrals yield infinity rather than a real number. For example, $\int_{1}^{\infty}\frac{1}{x}dx=\infty$. The reason is that, while $\frac{1}{x}$ is decreasing when $x\gt 1$, it approximates the x-axis ‘too slowly’, such that the area underneath grows fast enough so its sum is infinite. Suppose r.v. $X$ has pdf $\frac{1}{x^{2}}$, defined on domain $\left[1,\infty\right]$. We can show that this function is indeed a pdf, since $\int_{1}^{\infty}\frac{1}{x^{2}}dx=1$, and the function is positive over its domain. In this case, $E\left(X\right)=\int_{1}^{\infty}x\frac{1}{x^{2}}dx=\int_{1}^{\infty}\frac{1}{x}dx=\infty$. We have discovered an r.v. that does not have an expected value (i.e., it’s infinite). Intuitively, the expected value exists as long as the pdf approaches zero fast enough.

You will usually read the statement “if $\int_{-\infty}^{+\infty}\left|t\right|\,f_{X}\left(t\right)dt=\infty$, then $E\left(X\right)$ does not exist”, and may wonder about the absolute value. This is just a quick way to write the condition. To see this, first suppose $X$ were always positive. In this case, the absolute value would be redundant, but the statement would remain correct. If $X$ were always negative and with $E\left[X\right]=-\infty$, then the statement would still apply, because $E\left[\left|X\right|\right]=\infty$ remains true. Finally, suppose $X$ spans $\left(-\infty,\infty\right)$. In this case, $\int_{-\infty}^{0}\left|t\right|\,f_{X}\left(t\right)dt=-\infty$ and $\int_{0}^{\infty}\left|t\right|\,f_{X}\left(t\right)dt=+\infty$. Then, the expectation of $X$ does not exist, as it is indeterminate, but the statement $\int_{-\infty}^{+\infty}\left|t\right|\,f_{X}\left(t\right)dt=\infty$ still holds. So, $\int_{-\infty}^{+\infty}\left|t\right|\,f_{X}\left(t\right)dt=\infty$ is an efficient way to summarize the cases that may lead a r.v. to not have an expectation.

## Alternative notation

You may sometimes see the statement $E\left(X\right)=\int_{-\infty}^{+\infty}t dF_{X}\left(t\right)$ instead. This notation usually refers to the Lebesgue integral, where $dF_{X}\left(t\right)$ refers to a 'measure.' Rather than going down that rabbit hole, which we do not cover here, simply notice that by our previous rule of canceling differentials, $\int_{-\infty}^{+\infty}\left|t\right|dF_{X}\left(t\right)=\int_{-\infty}^{+\infty}\left|t\right|dF_{X}\left(t\right)\frac{dF_{X}\left(t\right)}{dt}\frac{dt}{dF_{X}\left(t\right)}=\int_{-\infty}^{+\infty}\left|t\right|\frac{dF_{X}\left(t\right)}{dt}dt$, and finally by noting that $\frac{dF_{X}\left(t\right)}{dt}=f_{X}\left(t\right)$, we obtain the familiar expression $\int_{-\infty}^{+\infty}t\,f_{X}\left(t\right)dt$.

## Basic properties of expectations

• Linearity: $E\left(ag\left(X\right)+bh\left(X\right)\right)=aE\left(g\left(X\right)\right)+bE\left(h\left(X\right)\right)$
• Order-preserving: $g\left(X\right)\leq h\left(X\right),\,\forall x\in\mathbb{R}\Rightarrow E\left(g\left(X\right)\right)\leq E\left(h\left(X\right)\right)$ (and equality holds if $g\left(X\right)=h\left(X\right)$)

# Moments of a Random Variable

We have already discussed the expectation of an r.v. $X$. It is useful to also consider expectations of specific transformations of $X$, called moments:

• The $k^{\mbox{th}}$ moment of $X$ is $E\left(X^{k}\right)=\mu_{k}^{'}$, $k\in\mathbb{N}$
• The expected value of $X$ can be written as $\mu$, and also as $\mu_{1}^{'}$ .
• The $k^{\mbox{th}}$ central/centered moment of $X$ is $E\left(\left(X-\mu\right)^{k}\right)=\mu_{k}$, $k\in\mathbb{N}$

## Moments and Functions of Moments

• The variance of $X$ is $\mu_{2}=\sigma^{2}=E\left(\left(X-\mu\right)^{2}\right)$
• The standard deviation of $X$ is $\sigma=\sqrt{\sigma^{2}}=\sqrt{E\left(\left(X-\mu\right)^{2}\right)}$
• The skewness of $X$ is $\alpha_{3}=E\left(\left(\frac{X-\mu}{\sigma}\right)^{3}\right)=\frac{E\left(\left(X-\mu\right)^{3}\right)}{Var\left(X\right)^{\frac{3}{2}}}$
• The kurtosis of $X$ is $\alpha_{4}=E\left(\left(\frac{X-\mu}{\sigma}\right)^{4}\right)=\frac{E\left(\left(X-\mu\right)^{4}\right)}{Var\left(X\right)^{2}}$

Both skewness and kurtosis characterize the shape of the distribution. Both denominators are always positive, and so act as normalizers.

In terms of skewness, as $\mu$ increases, $\alpha_{3}$ decreases, such that distributions with higher mean (usually lop-sided the right side) show negative skewness.

As for kurtosis, both the numerator and denominator capture variability, but the numerator weights outliers more. When $\alpha_{4}=3$, we say the distribution is mesokurtic: its tails represent the same relative mass as the center, and the tails decay at the same rate, as the normal distribution. When $\alpha_{4}\lt 3$, the distribution is leptokurtic (most of the mass is away from the tails), and when $\alpha_{4}\gt 3$, we say the distribution is platykurtic (the distribution appears flatter than the Normal).

## Standard Normal Distribution

Suppose $X\sim N\left(0,1\right)$, so $X$ is continuous with pdf $f_{X}\left(x\right)=\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^{2}}{2}\right)$.

Useful fact: In the case of the normal, $xf_{X}\left(x\right)=-\frac{d}{dx}f_{X}\left(x\right)$.

So,

$E\left(X\right)=\int_{-\infty}^{\infty}tf_{X}\left(t\right)dt=\left.f_{X}\left(t\right)\right|_{-\infty}^{\infty}=0-0=0$

and

$Var\left(X\right)=E\left(\left(X-\mu\right)^{2}\right)=E\left(\left(X-0\right)^{2}\right)=E\left(X^{2}\right)=\int_{-\infty}^{\infty}t^{2}f_{X}\left(t\right)dt$

where integration by parts yields

$\int_{-\infty}^{\infty}t^{2}f_{X}\left(t\right)dt=\underset{=0}{\underbrace{-\left.tf_{X}\left(t\right)\right|_{-\infty}^{\infty}}}+\underset{=1}{\underbrace{\int_{-\infty}^{\infty}f_{X}\left(t\right)dt}}=1.$

## Cauchy Distribution

In this case, $f_{X}=\frac{1}{\pi}\frac{1}{1+x^{2}}$, and $\int_{-\infty}^{\infty}\left|t\right|f_{X}\left(t\right)dt=\infty$ (i.e., its first moment does not exist).

Also, notice that because $\int_{-\infty}^{\infty}\left|t\right|^{k}f_{X}\left(t\right)dt\geq\int_{-\infty}^{\infty}\left|t\right|f_{X}\left(t\right)dt$ for $k\gt 1$, then the nonexistence of a moment implies nonexistence of higher moments as well.

## Some Useful Identities

• $Var\left(X\right)=E\left(X^{2}\right)-E\left(X\right)^{2}$.
• $E\left(aX+b\right)=aE\left(X\right)+b$.
• $Var\left(aX+b\right)=a^{2}Var\left(X\right)$.

## Normal Distribution

An r.v. $X$ is normally distributed with mean $\mu$ and variance $\sigma^{2}$, denoted as $X\sim N\left(\mu,\sigma^{2}\right)$, if $X$ is continuous with pdf $f_{X}\left(x\right)=\frac{1}{\sqrt{2\pi\sigma^{2}}}\exp\left(-\frac{\left(x-\mu\right)^{2}}{2\sigma^{2}}\right),x\in\mathbb{R}$.

Here’s a helpful fact: If $Z\sim N\left(0,1\right)$, then $X=\mu+\sigma Z\sim N\left(\mu,\sigma^{2}\right)$.

From this, it follows that:

• $E\left(X\right)=E\left(\mu+\sigma Z\right)=\mu+\sigma\underset{=0}{\underbrace{E\left(z\right)}}=\mu.$
• $Var\left(X\right)=Var\left(\mu+\sigma Z\right)=\sigma^{2}\underset{=1}{\underbrace{Var\left(Z\right)}}=\sigma^{2}.$

# Moment Generating Function

The moment generating function (m.g.f.) is a function that can be used to calculate moments of an r.v. in a different way than the one we defined before. We’ll talk about its use and intuition after we define it.

The m.g.f. of an r.v. $X$ is the function $M_{X}:\mathbb{R}\rightarrow\mathbb{R}_{+}$ given by $M_{X}\left(t\right)=E\left(\exp\left(tX\right)\right),t\in\mathbb{R}$.

First, notice that the m.g.f. is a function of $t$, not $X$. $X$ is “integrated out” by the expectation operator. (After we calculate the integral over $X$, it disappears.)

How does the m.g.f. operate? To see this, first, open up the expectation to obtain $\int_{-\infty}^{\infty}\exp\left(tx\right)f_{X}\left(x\right)dx$. Now, we can take advantage of the fact that the derivative of $\exp\left(tx\right)$ w.r.t. $t$ is $x\exp\left(tx\right)$. Taking the first derivative of $M_{X}\left(t\right)$ w.r.t. $t$ yields $\frac{d}{dt}M_{X}\left(t\right)=\frac{d}{dt}\int_{-\infty}^{\infty}\exp\left(tx\right)f_{X}\left(x\right)dx=\int_{-\infty}^{\infty}\frac{\partial}{\partial t}\exp\left(tx\right)f_{X}\left(x\right)dx=\int_{-\infty}^{\infty}x\exp\left(tx\right)f_{X}\left(x\right)dx$.

Granted, it’s not clear how this step may have helped. But evaluate this expression at $t=0$, and you will obtain $\int_{-\infty}^{\infty}x\underset{=1}{\underbrace{\exp\left(0x\right)}}f_{X}\left(x\right)dx=\int_{-\infty}^{\infty}xf_{X}\left(x\right)dx$, which is the formula for $E\left(X\right)$.

Suppose now that, rather than one derivative, we took $k$. In this case, we will obtain the equality $\frac{d}{dt^{k}}M_{X}\left(t\right)=\int_{-\infty}^{\infty}x^{k}\exp\left(tx\right)f_{X}\left(x\right)dx$. If we evaluate this function at $t=0$, we obtain the important equality

$\left.\frac{d}{dt^{k}}M_{X}\left(t\right)\right|_{t=0}=E\left(X^{k}\right)$.

We have established the main result of the m.g.f.: by taking $k$ derivatives, and then evaluating it at zero, we obtain a moment of $X$. One of the uses of the m.g.f. (which we will use later), is that if two random variables have the same m.g.f. (i.e., $M_{X}\left(t\right)=M_{Y}\left(t\right))$, then they have the same distribution, i.e., $F_{X}\left(x\right)=F_{Y}\left(x\right)$. Certain conditions are necessary. For starters, notice that we have already assumed that we can differente under the integral sign.

• The m.g.f. only applies if the moments of the r.v. exists.
• An r.v. may have moments, and yet the m.g.f. may yield infinity (notice that we’re taking an integral of an exponential, and so the integral will diverge if the pdf does not approximate zero fast enough). The typical example for this is the log-normal.
• Our proof relied on being able to move the derivative inside of the integral. We have covered the conditions for doing so in the previous lecture.
• If there exists a neighborhood near $t=0$ where the m.g.f. is finite, i.e. if $\exists h\gt 0:M_{X}\left(t\right)\lt \infty,t\in\left(-h,h\right)$, then it is possible to show that the m.g.f. uniquely identifies the c.d.f. of $X$. This means that if $M_{X}\left(t\right)=M_{Y}\left(t\right)$ and this condition is met, then $F_{X}\left(x\right)=F_{Y}\left(x\right),\forall x\in\mathbb{R}$. In other words, the m.g.f. can be used to identify the distribution of a random variable uniquely, provided it is finite in a neighborhood of zero. The reasons are complicated.
• Moreover, if the m.g.f. is finite in a neighborhood of zero, then all of the moments of the distribution exist.
• When the m.g.f. does not exist around a neighborhood of zero, we can always use the characteristic function to characterize a distribution. This function is given by $C_{X}:\mathbb{R}\rightarrow\mathbb{C}$, where $C_{X}\left(t\right)=E\left(\exp\left(itX\right)\right)=E\left(\text{cos}\left(tX\right)+i.sin\left(tX\right)\right)$.

## Standard Normal Distribution

Let's calculate the mgf of the standard normal distribution. When $X\sim N\left(0,1\right)$, then $M_{X}\left(t\right)=\int_{-\infty}^{\infty}\exp\left(tx\right)\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^{2}}{2}\right)dx$. We can rearrange the integrand:

$\int_{-\infty}^{\infty}\exp\left(tx\right)\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^{2}}{2}\right)dx=\int_{-\infty}^{\infty}\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{\left(x-t\right)^{2}}{2}\right)\exp\left(\frac{t^{2}}{2}\right)dx=\exp\left(\frac{t^{2}}{2}\right)\int_{-\infty}^{\infty}\underset{\text{pdf}\,N\left(t,1\right)}{\underbrace{\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{\left(x-t\right)^{2}}{2}\right)}}dx$

The first equality follows from completing the square, and the second equality uses the fact that the integral is w.r.t. $x$, not $t$. Note also that the integrand of the last expression is the pdf of the $Normal(t,1)$ distribution, and so its integral equals 1. Hence, we obtain $M_{X}\left(t\right)=\exp\left(\frac{t^{2}}{2}\right)$. We can test that it produces the mean and variance of $N\left(0,1\right)$.

## MGF of Affine Transformations

A useful fact about the m.g.f.: If $X$ has m.g.f. $M_{X}\left(t\right)$, then $M_{aX+b}\left(t\right)=\exp\left(bt\right)M_{X}\left(at\right)$. This is easily proved by expanding $E\left(\exp\left(aX+b\right)t\right)$. This implies the following for the general normal distribution:

Suppose $X\sim N\left(\mu,\sigma^{2}\right)$, such that $X=\mu+\sigma Z$ where $Z\sim N\left(0,1\right)$.

Then,

$M_{X}\left(t\right)=M_{\mu+\sigma Z}\left(t\right)=\exp\left(\mu t\right)M_{Z}\left(\sigma t\right)=\exp\left(\mu t\right)\exp\left(\frac{1}{2}\sigma^{2}t^{2}\right)=\exp\left(\mu t+\frac{1}{2}\sigma^{2}t^{2}\right)$.

We can now use this m.g.f. to calculate the moments of the general normal distribution $N\left(\mu,\sigma^{2}\right)$.