# Calculate variance given CDF

#### Houdini

##### New member
I already have the full solution to this so I'm not looking for an answer, I am hoping to get an explanation of certain parts that are unclear.

Question:
A random variable X has the following CDF:

$$\displaystyle f(x) =\left\{ \begin{array}{lr} 0& x<0\\ \frac{x^2-2x+2}{2} & 1 \le x < 2 \\ 1 & x \ge 2 \end{array} \right.$$

Calculate the variance of X.

Solution:
When $$\displaystyle 1<x<2$$ then E[X] can be calculated by first finding F'(x) and taking the integral $$\displaystyle \int_{1}^{2}x*F'(x)dx$$

Since x must take on a particular value I'm guessing that it must be considered discrete at x=1 so to account for this we must add $$\displaystyle 1*P[X=1]$$ to the above integral.

For x < 0 and $$\displaystyle x \ge 2$$ the variance seems to be zero but I don't see why that isn't involved somehow in the calculation since x is apparently any value from negative infinity to infinity. The solution says the the above two parts plus finding the second moments of them are enough to find the variance but it seems to me a piece is missing.

#### CaptainBlack

##### Well-known member
I already have the full solution to this so I'm not looking for an answer, I am hoping to get an explanation of certain parts that are unclear.

Question:
A random variable X has the following CDF:

$$\displaystyle f(x) =\left\{ \begin{array}{lr} 0& x<0\\ \frac{x^2-2x+2}{2} & 1 \le x < 2 \\ 1 & x \ge 2 \end{array} \right.$$

Calculate the variance of X.

Solution:
When $$\displaystyle 1<x<2$$ then E[X] can be calculated by first finding F'(x) and taking the integral $$\displaystyle \int_{1}^{2}x*F'(x)dx$$

Since x must take on a particular value I'm guessing that it must be considered discrete at x=1 so to account for this we must add $$\displaystyle 1*P[X=1]$$ to the above integral.

For x < 0 and $$\displaystyle x \ge 2$$ the variance seems to be zero but I don't see why that isn't involved somehow in the calculation since x is apparently any value from negative infinity to infinity. The solution says the the above two parts plus finding the second moments of them are enough to find the variance but it seems to me a piece is missing.
$$F'(x)=0$$ for $$x<1$$ and also for $$x > 2$$ so these regions can be considered to already be represented in your integral of $$xF'(x)$$

CB

Last edited: