10

Is there a formula for the variance of a (continuous, non-negative) random variable in terms of its CDF?

The only place I saw such formula was is Wikipedia's page for the Variance (https://en.wikipedia.org/wiki/Variance).

Unfortunately, I was not able to prove the expression there. Please, can anyone help?

3 Answers3

11

Here is a derivation of a formula for $E(X^2)$. The calculation is excessively informal. For "nice" density functions it is not difficult to justify. A similar calculation gives us $E(X)$. Then the variance is $E(X^2)-(E(X))^2$.

We find $\int_0^\infty x^2f(x)\,dx$ by integration by parts. Let $u=x^2$ and $dv=f(x)\,dx$. Then $du=2x\,dx$ and we can take $v=F(x)-1$. (Here we are being a little tricky.)

Then our integral is $$\left. x^2(1-F(x))\right|_0^\infty +\int_0^\infty 2x(1-F(x))\,dx.$$ The first part vanishes at both ends. So we find that

$$E(X^2)=\int_0^\infty 2x(1-F(x))\,dx.$$

André Nicolas
  • 507,029
4

Another potential derivation for $E[X^2]$ uses the tail-probability equality.

$Y = X^2$ is a nonnegative random variable, so the tail-probability equality applies:

$$E[Y] = \int_{y=0}^{\infty} Pr[Y \geq y] dy $$

Replace $Y = X^2$ and $y$ with appropriate expressions of $X$ and $x$:

$$E[X^2] = \int_{x^2=0}^{\infty} Pr[X^2 \geq x^2] dx^2 $$

Because we are assuming that $X$ is nonnegative, $Pr[X^2 \geq x^2] = Pr[X \geq x]$. We also change our variable of integration from $x^2$ to $x$ (essentially $u$-substitution) by noting that $dx^2 = 2xdx$. Making these changes, we get

$$E[X^2] = 2\int_{x=0}^{\infty}x Pr[X \geq x] dx $$

If you want it in CDF form, make the replacement $Pr[X \geq x] = 1 - F_X(x)$:

$$E[X^2] = 2\int_{x=0}^{\infty}x (1 - F_X(x)) dx $$

DGK
  • 163
  • 1
  • 6
0

I will write in more generality for any well behaved CDF (not necessarily non negative). Breaking the integral and recognizing $-2\mu_x\int xf(x)dx=-2\mu_x^2$ yields:

$$var(X)=\int_{-\infty}^\infty(x-\mu_x)^2 f(x)dx=\int_{-\infty}^\infty x^2 f(x)dx-\mu_x^2$$

To compute this integral with integrand $x^2f(x)$ we will separate the integral in two parts and use the change of the order of integration:

$$\int_0^\infty x^2 f_x(x)dx=\int_0^\infty \int_0^t 2t f_x(x) dtdx=$$ $$\int_0^\infty \int_t^\infty 2tf_x(x)dxdt=\int_0^\infty 2t(1-F_x(t))dt$$

Here, I denote the CDF by $F_x(t):=\int_{-\infty}^t f_x(x)dx$. A similar computation yields:

$$\int_{-\infty}^0 x^2 f_x(x) dx=\int_{-\infty}^0 \int_0^x 2t f_x(x) dt dx=-\int_{-\infty}^0 \int_x^0 2t f_x(x) dtdx=$$ $$-\int_{-\infty}^0 \int_{-\infty}^t 2t f_x(x) dxdt= -\int_{-\infty}^02t F_x(t) dt=$$ $$-\int_{\infty}^0 -2u F_x(-u)(-du)=\int_0^\infty 2u F_x(-u)du$$

So, we have:

$$ var(X)=\int_0^\infty 2x (1-F_x(x)+F_x(-x))dx-\mu_x^2$$

This formula is presented without proof in Alexander Mood's Introduction to the Theory of Statistics (page 67), so I am confident we haven't made any silly errors.

Kadmos
  • 1,907