As in the computation of, for example,
standard deviation, the estimation of a quantile depends upon whether one is operating with a
statistical population or with a
sample drawn from it. For a population, of discrete values or for a continuous population density, the -th -quantile is the data value where the cumulative distribution function crosses . That is, is a -th -quantile for a variable if : or, equivalently, and : where is the
probability function. For a finite population of equally probable values indexed from lowest to highest, the -th -quantile of this population can equivalently be computed via the value of . If is not an integer, then round up to the next integer to get the appropriate index; the corresponding data value is the -th -quantile. On the other hand, if is an integer then any number from the data value at that index to the data value of the next index can be taken as the quantile, and it is conventional (though arbitrary) to take the average of those two values (see
Estimating quantiles from a sample). If, instead of using integers and , the "-quantile" is based on a
real number with then replaces in the above formulas. This broader terminology is used when quantiles are used to
parameterize continuous probability distributions. Moreover, some software programs (including
Microsoft Excel) regard the minimum and maximum as the 0th and 100th percentile, respectively. However, this broader terminology is an extension beyond traditional statistics definitions.
Examples The following two examples use the Nearest Rank definition of quantile with rounding. For an explanation of this definition, see
percentiles.
Even-sized population Consider an ordered population of 10 data values [3, 6, 7, 8, 8, 10, 13, 15, 16, 20]. What are the 4-quantiles (the "quartiles") of this dataset? So the first, second and third 4-quantiles (the "quartiles") of the dataset [3, 6, 7, 8, 8, 10, 13, 15, 16, 20] are [7, 9, 15]. If also required, the zeroth quartile is 3 and the fourth quartile is 20.
Odd-sized population Consider an ordered population of 11 data values [3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20]. What are the 4-quantiles (the "quartiles") of this dataset? So the first, second and third 4-quantiles (the "quartiles") of the dataset [3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20] are [7, 9, 15]. If also required, the zeroth quartile is 3 and the fourth quartile is 20.
Relationship to the mean For any population probability distribution on finitely many values, and generally for any probability distribution with a mean and variance, it is the case that \mu - \sigma\cdot\sqrt{\frac{1-p}{p}} \le Q(p) \le \mu + \sigma\cdot\sqrt{\frac{p}{1-p}}\,, where is the value of the -quantile for (or equivalently is the -th -quantile for ), where is the distribution's
arithmetic mean, and where is the distribution's
standard deviation. In particular, the median is never more than one standard deviation from the mean. The above formula can be used to bound the value in terms of quantiles. When , the value that is
standard deviations above the mean has a lower bound \mu + z \sigma \ge Q\left(\frac{z^2}{1+z^2}\right)\,,\mathrm{~for~} z \ge 0. For example, the value that is standard deviation above the mean is always greater than or equal to , the median, and the value that is standard deviations above the mean is always greater than or equal to , the fourth quintile. When , there is instead an upper bound \mu + z \sigma \le Q\left(\frac{1}{1+z^2}\right)\,,\mathrm{~for~} z \le 0. For example, the value for will never exceed , the first decile. ==Estimating quantiles from a sample==