# Variance from cdf

I have an empirical cumulative probability distribution function $F$ for a random variable $X$ (non-negative). Is it possible to estimate the variance from $F$ ? I already estimated, numerically, the expected value this way: $E(X) = \int_{0}^{\infty}(1-F(x)dx$ and I wondered if there is a similar way to estimate variance. Thanks!!

• Since knowing $F$ is the same thing as knowing the individual data, what is to prevent you from estimating the variance from the data in any way whatsoever?
– whuber
Commented Mar 15, 2016 at 17:16
• @whuber - it's more fun this way. To "answer" the question, it should be clear that $\mathbb{E}X^2 = \int_0^{\infty}x(1-F(x))dx$, and you can go from there, but it's not purely in terms of the distribution function, I admit. Commented Mar 15, 2016 at 17:57
• @jbowman You seem to be describing a calculation rather than an estimate. My points are that $F$ and the dataset are mathematically equivalent; that any calculation involving one can mechanically be converted to a calculation involving the other; and that using $F$ counterproductively obscures this fact, making all the usual data-based estimators seem unavailable. These imply there isn't a new question here, because it merely asks "how do I estimate a variance," which is answered in a great number of threads.
– whuber
Commented Mar 15, 2016 at 18:10
• @whuber - oh, sure, you're right of course. But sometimes it's fun to do something in an admittedly uselessly complex but still correct way, or at least to know if some interesting relationship can be extended to other interesting (albeit pointless, from a computational frame of reference) relationships. Commented Mar 15, 2016 at 19:36
• @jbowman I agree with you. I see there is some content to this question provided we strip away the unnecessary distraction of representing data in terms of an ECDF. It comes down to a question about summation by parts. For instance, "$\int dF(x)$" is an obscure way to write "$(1/n)\sum x_i$" and "$\int_0^\infty(1-F(x))dx$" is the equivalent formulation in terms of summation by parts. In effect, we have $$\bar x=\frac{1}{n}\sum_{i=1}^n x_i=\frac{1}{n}\sum_{i=0}^{n-1}(n-i)(x_{i+1}-x_i),$$ understanding $x_0=0\le x_1\le\cdots\le x_n$. There's a similar equation for the second moment of the data.
– whuber
Commented Mar 15, 2016 at 21:07

As usual, I found my answer just after asking, so here in my case, I was just looking for: $Var(X) = 2\int_{0}^{\infty}x(1-F(x))dx - (\int_{0}^{\infty}(1-F(x))dx)^{2}$.
• (1) This will work only when all data are positive (2) in which case it's directly related to the usual formula for variance (with a $1/n$ denominator). The relationship is that the sums for the sample moments are expressed using summation by parts. Note that it is a biased estimator of the variance rather than the familiar one with $1/(n-1)$ in the denominator.