# Expected Value Function

My text-book defines expected value as $$E(X) = \mu_x = \sum_{x \in D} ~x \cdot p(x)$$ And so, if I was to find the expected value of a random variable $X$, where $X = 1,2,3$, then it would resemble this: $$E(X)= \sum_{x=1}^3~ x \cdot p(x)= 1\cdot p(1) + 2\cdot p(2) + 3 \cdot p(3)$$ Furthermore, if I wanted to calculate $E(X^2)$, it would be $E(X^2) = 1^2 \cdot P(1) + 2^2 \cdot p(2) + 3^2 \cdot p(3)$. My question is, why don't we square the x-values in the probability function $p(x)$?

Also, is computing the expected value a way of calculating the average of the random variable? It seems a little odd to calculate it that way.

PS: If any use of notation, or vocabulary, is incorrect, please inform me.

• The differences between using \Sigma and using \sum in TeX are these: $\displaystyle\Sigma_{x\in D}$ versus $\displaystyle\sum_{x\in D}$. That's why \sum is standard for this occasion. Feb 17, 2013 at 19:36
• I think you might want to have a look at the Law of the Unconscious Statistican (LOTUS) to get a hint on how to calculate the expected value of a function $g(x)$ of an r.v. $X$. May 12, 2016 at 23:29

Let $Y=X^2$. Then $Y$ takes on the values $1$, $4$, and $9$ respectively when $X$ takes on the values $1$, $2$, and $3$.

Thus $p_Y(1)=p_X(1)$, $p_Y(4)=p_X(2)$, and $p_Y(9)=p_X(3)$.

Now for calculating $E(Y)$ we just use the formula the post started with, namely $$E(Y)=\sum_y yp_Y(y).$$ In our case, we get $1\cdot p_Y(1)+4\cdot p_Y(4)+9\cdot p_Y(9)$. Equivalently, $E(Y)= 1\cdot p_X(1)+4\cdot p_X(2)+9\cdot p_X(3)$.

To answer your question more explicitly, we do not use $1^2(p_X(1))^2+2^2(p_X(2))^2+3^2(p_X(3))^2$ because, for example, $\Pr(X^2=3^2)$ is not $(\Pr(X=3))^2$. In fact, $\Pr(X^2=3^2)=\Pr(X=3)$.

As to your question about average, yes, the mean is a very important measure of average value. The only serious competitor is the median.

Mean and median can be quite different. For example, imagine a population in which a small minority is insanely rich, while the vast majority of the population is struggling. Then the mean income of the population may be substantially higher than the median income. Is either one a "better" measure of average wealth? I would argue that in this case the median is ordinarily of greater relevance. But for certain planning purposes, such as level of tax revenues, the mean may be more useful.

The mathematics of the mean is substantially simpler than the mathematics of the median. For example, the mean of a sum of two random variables is the sum of the means. The median of a sum is a far more complicated object.

There were two questions. The first question: Why don't we square the $x$ values in the calculation for the expected value of $X^2$.

Suppose $Y = g(X)$.

\begin{aligned} E(Y) & \stackrel{\text{(a)}}{=} \sum_{y\in{S_Y}}yP_Y(y)\\ & \stackrel{\text{(b)}}{=} \sum_{y\in{S_Y}}y\sum_{x:g(x) = y}P_X(x)\\ & \stackrel{\text{(c)}}{=} \sum_{y\in{S_Y}}\sum_{x:g(x) = y}yP_X(x)\\ & \stackrel{\text{(d)}}{=} \sum_{y\in{S_Y}}\sum_{x:g(x) = y}g(x)P_X(x)\\ & \stackrel{\text{(e)}}{=} \sum_{x\in{S_X}}g(x)P_X(x)\\ \end{aligned}

(a): The definition of expected value of a discrete random variable, as you have supplied.

(b): Because the probability of random variable $Y$ taking on a value $g(x)$ is equal to the sum of the probability of all the values of $x$ which will map to $g(x)$.

(c): Interchanging the summation.

(d): Because of the condition in the summation, we can replace $y$ by $g(x)$.

(e): Because enumerating across all $y$, then enumerating across all $x$ such that $g(x) = y$, is equivalent to enumerating across all $x$ since every $x$ must map to exactly one $y$. (Multiple $x$ could map to the same $y$).

So, in your instance, set $g(x) = x^2$ to obtain the result.

The second question: Why is expected value defined the way it is defined?

Expected value can be thought of as the center of mass, if we set $P_X(x)$ to be the mass located at a distance $x$ from the origin. It corresponds exactly with the arithmetic average when the distribution of $X$ is uniform.

For computing $E[X^2]$, the probability is still taken over $X$ and not $X^2$. Otherwise, if you make $Y=X^2$ the random variable and then compute $E[Y]$, the only operation that you effectively did is to relabel the random variables (well, although only considering positive values): all the values taken by $|X|$ will also be taken by $Y$, so for positive values of $X$, computing $E[X^2]$ would be exactly like computing $E[X]$. But computing $E[X^2]$ gives you more information!

The expected value is the weighted average. "Normally" (in daily life), when you take an average, all the values have the same weight. The average salary of your family members, for instance. But say you wanted the average salary in your country, then it's nice to work with, say, the probability of a certain salary being had. Making this latter problem more concrete, you could approximate the average national salary by taking every integer multiple of \$1000, and finding out the proportion of people with this salary. Then the weighted average gives you the true national average salary.