4.1.2 Expected Value and Variance

As we mentioned earlier, the theory of continuous random variables is very similar to the theory of discrete random variables. In particular, usually summations are replaced by integrals and PMFs are replaced by PDFs. The proofs and ideas are very analogous to the discrete case, so sometimes we state the results without mathematical derivations for the purpose of brevity.

Remember that the expected value of a discrete random variable can be obtained as $$EX=\sum_{x_k \in R_X} x_k P_X(x_k).$$ Now, by replacing the sum by an integral and PMF by PDF, we can write the definition of expected value of a continuous random variable as

$$EX= \int_{-\infty}^{\infty} xf_X(x)dx$$



Example

Let $X \sim Uniform(a,b)$. Find $EX$.

  • Solution
    • As we saw, the PDF of $X$ is given by \begin{equation} \nonumber f_X(x) = \left\{ \begin{array}{l l} \frac{1}{b-a} & \quad a < x < b\\ 0 & \quad x < a \textrm{ or } x > b \end{array} \right. \end{equation} so to find its expected value, we can write
      $EX$ $= \int_{-\infty}^{\infty} xf_X(x)dx$
      $=\int_{a}^{b} x (\frac{1}{b-a}) dx$
      $=\frac{1}{b-a} \bigg[ \frac{1}{2}x^2 \bigg]_{a}^{b} $
      $=\frac{a+b}{2}.$

      This result is intuitively reasonable: since $X$ is uniformly distributed over the interval $[a,b]$, we expect its mean to be the middle point, i.e., $EX=\frac{a+b}{2}$.


Example

Let $X$ be a continuous random variable with PDF \begin{equation} \nonumber f_X(x) = \left\{ \begin{array}{l l} 2x & \quad 0 \leq x \leq 1\\ 0 & \quad \text{otherwise} \end{array} \right. \end{equation} Find the expected value of $X$.

  • Solution
    • We have
      $EX$ $= \int_{-\infty}^{\infty} xf_X(x)dx$
      $=\int_{0}^{1} x (2x) dx$
      $=\int_{0}^{1} 2x^2 dx$
      $=\frac{2}{3}.$



Expected Value of a Function of a Continuous Random Variable

Remember the law of the unconscious statistician (LOTUS) for discrete random variables: $$\hspace{70pt} E[g(X)]=\sum_{x_k \in R_X} g(x_k)P_X(x_k) \hspace{70pt} (4.2)$$ Now, by changing the sum to integral and changing the PMF to PDF we will obtain the similar formula for continuous random variables.

Law of the unconscious statistician (LOTUS) for continuous random variables: $$\hspace{70pt} E[g(X)]=\int_{-\infty}^{\infty} g(x) f_X(x) dx \hspace{70pt} (4.3)$$

As we have seen before, expectation is a linear operation, thus we always have



Example
Let $X$ be a continuous random variable with PDF \begin{equation} \nonumber f_X(x) = \left\{ \begin{array}{l l} x+\frac{1}{2} & \quad 0 \leq x \leq 1\\ 0 & \quad \text{otherwise} \end{array} \right. \end{equation} Find $E(X^n)$, where $n \in \mathbb{N}$.
  • Solution
    • Using LOTUS we have
      $E[X^n]$ $=\int_{-\infty}^{\infty} x^n f_X(x) dx$
      $= \int_{0}^{1} x^n (x+\frac{1}{2}) dx$
      $= \bigg[\frac{1}{n+2}x^{n+2}+\frac{1}{2(n+1)}x^{n+1} \bigg]_{0}^{1}$
      $=\frac{3n+4}{2(n+1)(n+2)}.$



Variance

Remember that the variance of any random variable is defined as $$\textrm{Var}(X)=E\big[(X-\mu_X)^2\big]=EX^2-(EX)^2.$$ So for a continuous random variable, we can write

$$\textrm{Var}(X)$$ $$=E\big[(X-\mu_X)^2\big]=\int_{-\infty}^{\infty} (x-\mu_X)^2 f_X(x)dx$$
$$=EX^2-(EX)^2=\int_{-\infty}^{\infty} x^2 f_X(x)dx-\mu_X^2$$


Also remember that for $a,b \in \mathbb{R}$, we always have $$\textrm{Var}(aX+b)=a^2 \textrm{Var}(X).\hspace{70pt} (4.4)$$



Example
Let $X$ be a continuous random variable with PDF \begin{equation} \nonumber f_X(x) = \left\{ \begin{array}{l l} \frac{3}{x^4} & \quad x \geq 1\\ 0 & \quad \text{otherwise} \end{array} \right. \end{equation} Find the mean and variance of $X$.
  • Solution
    • $E[X]$ $=\int_{-\infty}^{\infty} x f_X(x) dx$
      $= \int_{1}^{\infty} \frac{3}{x^3} dx$
      $= \bigg[-\frac{3}{2}x^{-2} \bigg]_{1}^{\infty}$
      $=\frac{3}{2}.$

      Next, we find $EX^2$ using LOTUS,
      $E[X^2]$ $=\int_{-\infty}^{\infty} x^2 f_X(x) dx$
      $= \int_{1}^{\infty} \frac{3}{x^2} dx$
      $= \bigg[-3x^{-1} \bigg]_{1}^{\infty}$
      $=3.$

      Thus, we have $$\textrm{Var}(X)=EX^2-(EX)^2=3-\frac{9}{4}=\frac{3}{4}.$$



The print version of the book is available on Amazon.

Book Cover


Practical uncertainty: Useful Ideas in Decision-Making, Risk, Randomness, & AI

ractical Uncertaintly Cover