Statistics · real student question

A continuous random variable X has density f(x) = x for 0 < x <= 1, f(x) = 2 - x for 1 <= x < 2, and 0 otherwise. Find E(X) and Var(X).

Question

A continuous random variable XX has probability density function

f(x)={x,0<x12x,1x<20,otherwisef(x)=\begin{cases}x,&0<x\le 1\\ 2-x,&1\le x<2\\ 0,&\text{otherwise}\end{cases}

Find E(X)E(X) and D(X)=Var(X)D(X)=\operatorname{Var}(X).

Step-by-step solution

  1. Check that ff really is a density. A legitimate pdf is non-negative and integrates to 11:

    01xdx+12(2x)dx=12+[2xx22]12=12+(232)=12+12=1\int_0^1x\,dx+\int_1^2(2-x)\,dx=\frac12+\left[2x-\frac{x^2}{2}\right]_1^2=\frac12+\left(2-\frac32\right)=\frac12+\frac12=1

    Geometrically this is a triangle with base 22 and height 11, area 1221=1\frac12\cdot2\cdot1=1. Confirming this first is cheap insurance against a mis-copied piece.

  2. Compute E(X)E(X) piece by piece. Because the density is defined in two pieces, the expectation integral splits at x=1x=1:

    E(X)=01xxdx+12x(2x)dx=01x2dx+12(2xx2)dxE(X)=\int_0^1x\cdot x\,dx+\int_1^2x(2-x)\,dx=\int_0^1x^{2}dx+\int_1^2\left(2x-x^{2}\right)dx

    =13+[x2x33]12=13+(4323)=13+23=1=\frac13+\left[x^{2}-\frac{x^{3}}{3}\right]_1^2=\frac13+\left(\frac43-\frac23\right)=\frac13+\frac23=1

  3. Notice the shortcut you could have used. The triangle is symmetric about x=1x=1: f(1u)=1uf(1-u)=1-u and f(1+u)=1uf(1+u)=1-u for 0u10\le u\le1. For any density symmetric about a point, the mean is that point, so E(X)=1E(X)=1 without integrating at all. The integral above is then just a check.

  4. Compute E(X2)E(X^{2}), which symmetry cannot give you.

    E(X2)=01x3dx+12x2(2x)dx=14+[2x33x44]12E(X^{2})=\int_0^1x^{3}dx+\int_1^2x^{2}(2-x)\,dx=\frac14+\left[\frac{2x^{3}}{3}-\frac{x^{4}}{4}\right]_1^2

    Evaluating the bracket at 22 gives 1634=43\frac{16}{3}-4=\frac43; at 11 it gives 2314=512\frac23-\frac14=\frac{5}{12}. So the second integral is 43512=1112\frac43-\frac{5}{12}=\frac{11}{12} and

    E(X2)=14+1112=312+1112=1412=76E(X^{2})=\frac14+\frac{11}{12}=\frac{3}{12}+\frac{11}{12}=\frac{14}{12}=\frac{7}{6}

  5. Apply the shortcut formula for the variance.

    D(X)=E(X2)[E(X)]2=7612=7666=160.1667D(X)=E(X^{2})-\left[E(X)\right]^{2}=\frac76-1^{2}=\frac{7}{6}-\frac{6}{6}=\frac16\approx0.1667

    The standard deviation is 1/6=0.408\sqrt{1/6}=0.408.

  6. Check that the answer is plausible. All the probability lives in (0,2)(0,2), an interval of length 22, so the standard deviation must be well under 11; 0.4080.408 is comfortable. It is also smaller than the 0.5770.577 of a uniform distribution on (0,2)(0,2), which is exactly right — the triangular density concentrates mass near its centre instead of spreading it evenly.

Answer

E(X)=1,D(X)=16E(X)=1,\qquad D(X)=\frac{1}{6}

Need to solve a different problem like this? Open the solver →