title: How to get a percentile for an empirical data distribution and get it's x-coordinate?
body: <p>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.
  <img src="https://i.stack.imgur.com/D3Ypf.png" alt="enter image description here"></p>
  
  <p>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?</p>
  
  <p>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.</p>
  
  <p>Thank you in advance!</p>
  
  <p><strong>EDIT:</strong>
  some example code for almost what I want.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>