# Calculate expectation from empirical cdf

I have a empirical cumulative probability distribution function for a random variable. The random variable is "time to failure" and I have the full curve i.e till the probability reaches 1. I want to know Mean Time To Failure i.e expectation of that random variable. Is there any standard method to find mean from an empirical distribution.

I am getting the empirical CDF (as discrete values) as output from a "model checking tool" which uses iterative numerical computation techniques to get those probabilities. For example, let F(x)=P(X<=t) is the CDF of the random variable X where X stands for time between failure. To plot the curve of F(X) vs t I am varying t with some step size, calculating F(X) for that t using the "model checking tool" and adding the points to get the curve. I can use small step size to get the more accurate curve. So, I have access to only this CDF values at different t. From this values I want to do a good estimate of mean value of X.

• It is considered somewhat impolite to simultaneously post (or nearly so, in your case) the same question in multiple forums. See the various meta sites for more details. Crosspost: math.stackexchange.com/questions/61460/… – cardinal Sep 3 '11 at 4:18
• well, it's a fact that $E(X) = \int_{0}^{\infty} \big(1-F(x) \big) dx$ for a non-negative random variable $X$ with cdf $F$. Perhaps you can use this fact while invoking the convergence of the empirical cdf to the true one to get an estimate. – Macro Sep 3 '11 at 4:25
• @cardinal: Sorry for posting it twice. Actually, someone in math exchange has suggested me to post in stats.stackexchange as it is relevant to statistics – RIchard Williams Sep 3 '11 at 4:40
• You've received pretty explicit answers there, including the one that @Macro lists. Where do your remaining doubts lie? – cardinal Sep 3 '11 at 4:49
• Let's resolve it this way -- please edit the Q to express your remaining doubts or it will be closed. – user88 Sep 3 '11 at 11:26

Given the empirical CDF, $F_n(x)$, call the percent points of the CDF $\alpha$ (which range from $0$ to $1$) and their corresponding values VaR$_\alpha$ (Value at Risk). VaR$_\alpha$ is simply $F_n^{-1}(\alpha)$ You can use the fact that: $$E(X) = \int_0^1 VaR_\alpha\;d\alpha$$
This is actually the dual of the relationship @Macro stated, however, instead of adding up vertical slices across the x-axis from $F(x)$ to $1$, you are adding horizontal slices from the y-axis to F(x) up to $y=1$. It is the same area.
To actually do the integration, I'd recommend the trapezoid rule, so given $n$ entries in the CDF we have: $$E(X) \approx \sum_{k=0}^{n-1} \frac{VaR_{k+1} + VaR_{k}}{2}\cdot\left(\alpha_{k+1}-\alpha_{k}\right)$$
• Beyond @Glen_b's point about VaR, percentiles are values of $X$, not the associated cumulative probabilities. For example, $\alpha = 0.5$ defines the median, but the median is the percentile, not $\alpha$. Some people say percent points, which may be where you are getting confused. – Nick Cox Sep 8 '13 at 23:43