Post · 4 min read· pp. 221–224

4.1.2 Expected Value and Variance


Video Available

Video Available

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=∑xk∈RXxkPX(xk).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=∫−∞∞xfX(x)dxEX= \int_{-\infty}^{\infty} xf_X(x)dx


Example

Let X∼Uniform(a,b)X \sim Uniform(a,b). Find EXEX.

  • Solution
    • As we saw, the PDF of XX 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

      EXEX=∫−∞∞xfX(x)dx= \int_{-\infty}^{\infty} xf_X(x)dx
      =∫abx(1b−a)dx=\int_{a}^{b} x (\frac{1}{b-a}) dx
      $=\frac{1}{b-a} \bigg[ \frac{1}{2}x^2 \bigg]_{a}^{b} $
      =a+b2.=\frac{a+b}{2}.

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


Example

Let XX 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 XX.

  • Solution
    • We have

      EXEX=∫−∞∞xfX(x)dx= \int_{-\infty}^{\infty} xf_X(x)dx
      =∫01x(2x)dx=\int_{0}^{1} x (2x) dx
      =∫012x2dx=\int_{0}^{1} 2x^2 dx
      =23.=\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:

E[g(X)]=∑xk∈RXg(xk)PX(xk)(4.2)\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:

E[g(X)]=∫−∞∞g(x)fX(x)dx(4.3)\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

  • E[aX+b]=aEX+bE[aX+b]=aEX+b, for all a,b∈Ra,b \in \mathbb{R}, and
  • E[X1+X2+...+Xn]=EX1+EX2+...+EXnE[X_1+X_2+...+X_n]=EX_1+EX_2+...+EX_n, for any set of random variables X1,X2,...,XnX_1, X_2,...,X_n.

Example Let XX 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(Xn)E(X^n), where n∈Nn \in \mathbb{N}.

  • Solution
    • Using LOTUS we have

      E[Xn]E[X^n]=∫−∞∞xnfX(x)dx=\int_{-\infty}^{\infty} x^n f_X(x) dx
      =∫01xn(x+12)dx= \int_{0}^{1} x^n (x+\frac{1}{2}) dx
      =[1n+2xn+2+12(n+1)xn+1]01= \bigg[\frac{1}{n+2}x^{n+2}+\frac{1}{2(n+1)}x^{n+1} \bigg]_{0}^{1}
      =3n+42(n+1)(n+2).=\frac{3n+4}{2(n+1)(n+2)}.

Variance

Remember that the variance of any random variable is defined as

Var(X)=E[(X−μX)2]=EX2−(EX)2.\textrm{Var}(X)=E\big[(X-\mu_X)^2\big]=EX^2-(EX)^2.
So for a continuous random variable, we can write

Var(X)\textrm{Var}(X)
=E[(X−μX)2]=∫−∞∞(x−μX)2fX(x)dx=E\big[(X-\mu_X)^2\big]=\int_{-\infty}^{\infty} (x-\mu_X)^2 f_X(x)dx
=EX2−(EX)2=∫−∞∞x2fX(x)dx−μX2=EX^2-(EX)^2=\int_{-\infty}^{\infty} x^2 f_X(x)dx-\mu_X^2

Also remember that for a,b∈Ra,b \in \mathbb{R}, we always have

Var(aX+b)=a2Var(X).(4.4)\textrm{Var}(aX+b)=a^2 \textrm{Var}(X).\hspace{70pt} (4.4)


Example Let XX 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 XX.

  • Solution
    • E[X]E[X]=∫−∞∞xfX(x)dx=\int_{-\infty}^{\infty} x f_X(x) dx
      =∫1∞3x3dx= \int_{1}^{\infty} \frac{3}{x^3} dx
      =[−32x−2]1∞= \bigg[-\frac{3}{2}x^{-2} \bigg]_{1}^{\infty}
      =32.=\frac{3}{2}.

      Next, we find EX2EX^2 using LOTUS,

      E[X2]E[X^2]=∫−∞∞x2fX(x)dx=\int_{-\infty}^{\infty} x^2 f_X(x) dx
      =∫1∞3x2dx= \int_{1}^{\infty} \frac{3}{x^2} dx
      =[−3x−1]1∞= \bigg[-3x^{-1} \bigg]_{1}^{\infty}
      =3.=3.

      Thus, we have

      Var(X)=EX2−(EX)2=3−94=34.\textrm{Var}(X)=EX^2-(EX)^2=3-\frac{9}{4}=\frac{3}{4}.