# I have data from an unknown, continuous probability distribution. How do I calculate a percentile/quantile?

I'm going to collect a sample of data that comes from an unknown, likely continuous, probability distribution. I don't really know anything about the data other than that it's somewhat chaotic. I want to know how to calculate a given percentile.

For example, suppose the dataset is 10 items, but I want to calculate the distribution's 95th percentile (the dataset isn't actually that small, this is just an example.) 95% of 10 is 9.5, and obviously there's no 9.5th smallest item.

So how do I calculate a percentile of this unknown distribution?

• You can use the sample estimates of the mean and standard deviation, but you can say a little more than that on the basis of prior knowledge. Do know anything about the data? What do the numbers represent? Dec 3, 2021 at 20:33
• (This seems like an XY problem where you have question X (how to calculate quantiles) that you think you can solve by method Y (estimate the entire distribution), so you ask about Y instead of X, so I will assume you are interested in X.) The documentation in R for quantile, accessed via ?quantile, gives insights into methods of calculating quantiles. For instance, for x <- seq(1, 100, 1), I get different answers for quantile(x, 0.504) and quantile(0.505).
– Dave
Dec 3, 2021 at 21:06
• @Dave thanks but I use TypeScript, not R. Dec 3, 2021 at 21:19
• The documentation discusses theory, which is independent of software.
– Dave
Dec 3, 2021 at 21:25
• @Dave Thanks for pointing me to the documentation,but it's so full of mathematical jargon that it's difficult for me to follow along (I didn't take any statistics after graduating High School) Dec 3, 2021 at 21:35

If you are familiar with a software package you can start by producing a histogram of the data and request the software to produce sample estimates of the percentiles. You can then investigate the calculations of percentile estimates by hand to better understand the methodology and compare your work to the software's results. In the example you provided if you have a sample of $$10$$ ordered values and are interested in estimating the $$95^{th}$$ percentile of the population, one approach would be to take the average of the $$9^{th}$$ and $$10^{th}$$ ordered values in your sample.