I'm reporting on methods that use discrete distribution data, for example:

d <- density(rnorm(10) * 3 + 10, n=201, from=0, to=20)  # don't focus on this line!
x <- d[["x"]]   # these are the discrete points 0.0, 0.1, ..., 19.9, 20.0
fx <- d[["y"]]  # 0.000977 0.001116 0.001271 0.001445 0.001639 ...

In this example, the only data I have are two vectors of (e.g.) 201 points: the discrete points $x$ and their frequency intensities $f(x)$.

My question relates to an R function to approximate the point $x_\beta$ along $x$ where the cumulative frequency exceeds $\beta$, e.g. 0.2:

beta <- 0.2
x_beta <- approx(cumsum(fx) / sum(fx), x, beta)$y  # 6.524198

Or shown graphically as a cumulative distribution with cumsum(fx) / sum(fx):


How should the determination of $x_\beta$ be reported? Is it possible to describe this with typeset equations? For example, I'm sure there are some $\sum$ symbols, but I've never seen a typeset formula for cumsum, so I'm lost on where to start. Or should this method be described just as words?

  • $\begingroup$ This is an empirical quantile, no? $\endgroup$
    – Xi'an
    Mar 13, 2016 at 14:22

1 Answer 1


As the comment suggested, you're talking about an Empirical Quantile Function (EQF).

cumsum(fx) / sum(fx) can be written as:

For $x \in \{X_{1},X_{2},..,X_{n}\}$, define $$ \bar{g}(x) = \frac{\sum_{i=1}^{n} f(X_{i}) \mathbf{1}(X_{i}\leq x)}{\sum_{i=1}^{n} f(X_{i})} $$ Where $\mathbf{1}(.)$ is the indicator function.

Then let $g(x)$ be the linear interpolation. See https://en.wikipedia.org/wiki/Linear_interpolation for various ways to write this up. To be rigorous with the definition, you'll need to ensure that $ 0 \leq g(x) \leq 1$ for all $x$.

Finally, $x_{\beta} = g^{-1}(\beta)$, where again, you'll have to be a little careful with the inverse so that it's well defined.

I think spending a little time reading about Empirical Density Functions and Empirical Quantile Functions should clear things up for you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.