How to get a percentile for an empirical data distribution and get it's x-coordinate?
Question: I have some discrete data values, that taken together form some sort of
distribution. This is one of them, but they are different with the peak being
in all possible locations, from 0 to end. ![enter image description
here](http://i.stack.imgur.com/D3Ypf.png)

So, I want to use it's quantiles (percentiles) in Python. I think I could
write some sort of function, that would some up all values starting from zero,
until it reaches desired percent. But probably there is a better solution? For
example, to create an empirical distribution of some sort in SciPy and then
use SciPy's methods of calculating percentiles?

In the very end I need x-coordinates of a left percentile and a right
percentile. One could use 20% and 80% percentiles as an example, I will have
to find the best numbers for my case later.

Thank you in advance!

**EDIT:** some example code for almost what I want.

    
    
    import numpy as np
    np.random.seed(0)
    distribution = np.random.normal(0, 1, 1000)
    left, right = np.percentile(distribution, [20, 80])
    print left, right
    

This returns percentiles themselves, I need to get their x-coordinates
somehow. For normal distribution here it is possible, obviously, but I have a
distribution of an unknown shape, so if a percentile isn't equal to one of the
values (which is the most common thing, obviously), it becomes much more
complicated.


Answer: if you are looking for empirical CDF then you may use statsmodels
[ECDF](http://statsmodels.sourceforge.net/devel/generated/statsmodels.tools.tools.ECDF.html).
For percentiles/quantiles you can use numpy
[percentile](http://docs.scipy.org/doc/numpy/reference/generated/numpy.percentile.html)

