The formula
Position = (n − 1) × p / 100, interpolating between the two values around it
What it means
The pth percentile is the value below which p per cent of the data fall. Quartiles are three specific percentiles: the 25th, the 50th — which is the median — and the 75th, and between the first and the third sits the middle half of the data. When the position lands between two values something has to be decided, and here it is interpolated: you take the matching fraction between the value below and the one above.
How to work it out by hand
- Sort the values from smallest to largest
- Work out the position: (n − 1) × p ÷ 100, counting from zero
- If the position is a whole number, the percentile is that value
- If not, interpolate between the value before and the one after using the decimal part
What is worth knowing
There are at least nine different ways to compute percentiles and none of them is the correct one: they differ in what to do when the position falls between two values. Linear interpolation is what Excel's PERCENTILE.INC, Google Sheets and Python's numpy use by default, so it is the one most likely to match whatever you are being asked for. With large samples the methods barely differ; with six values they can differ noticeably.