Median is a robust indicator of central tendency and much less affected by outliers
than the sample mean. The median is estimated by the value exactly in the middle of
the sorted set of samples and thus seperating the higher half of the data from the lower half.
* _Nist_: Using the method [recommended](http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm) by NIST. This is the default method.
* _Nearest_: Using the [nearest rank](http://en.wikipedia.org/wiki/Percentile#Nearest_Rank) method.
* _Excel_: Using the [method](http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm) that is also used by Microsoft Excel.
* _Interpolation_: Using linear interpolation between the two nearest ranks, see [wikipedia](http://en.wikipedia.org/wiki/Percentile#Linear_Interpolation_Between_Closest_Ranks).
`Statistics.Median(data)`
`SortedArrayStatistics.Median(data)`
`ArrayStatistics.MedianInplace(data)`
The median is only unique if the sample size is odd. This implementation internally
uses the default quantile definition, which is equivalent to mode 8 in R and is approximately
median-unbiased regardless of the sample distribution. If you need another convention, use
`QuantileCustom` instead, see below for details.
#### Quartiles and the 5-number summary
Quartiles group the ascendingly sorted data into four equal groups, where each
group represents a quarter of the data. The lower quartile is estimated by
the middle number between the first two groups and the upper quartile by the middle
number between the remaining two groups. The middle number between the two middle groups
estimates the median as discussed above.
`Statistics.LowerQuartile(data)`
`Statistics.UpperQuartile(data)`
`SortedArrayStatistics.LowerQuartile(data)`
`SortedArrayStatistics.UpperQuartile(data)`
`ArrayStatistics.LowerQuartileInplace(data)`
`ArrayStatistics.UpperQuartileInplace(data)`
Using that data we can provide a useful set of indicators usually named 5-number summary,
which consists of the minimum value, the lower quartile, the median, the uppper quartile and
the maximum value. All these values can be visualized in the popular box plot diagrams.
`Statistics.FiveNumberSummary(data)`
`SortedArrayStatistics.FiveNumberSummary(data)`
`ArrayStatistics.FiveNumberSummaryInplace(data)`
The difference between the upper and the lower quartile is called inter-quartile range (IQR)
and is a robust indicator of spread. In box plots the IQR is the total height of the box.
`Statistics.InterquartileRange(data)`
`SortedArrayStatistics.InterquartileRange(data)`
`ArrayStatistics.InterquartileRangeInplace(data)`
Just like median, quartiles use the default R8 quantile definition internally.
#### Percentiles
Precentiles extend the concept further by grouping the sorted values into 100
equal groups and looking at the 101 places (0,1,..,100) between and around them.
The 0-percentile represents the minimum value, 25 the first quartile, 50 the median,
75 the upper quartile and 100 the maximum value.
`Statistics.Percentile(data, p)`
`Statistics.PercentileFunc(data)`
`SortedArrayStatistics.Percentile(data, p)`
`ArrayStatistics.PercentileInplace(data, p)`
Just like median, percentiles use the default R8 quantile definition internally.
#### Quantiles
Instead of grouping into 4 or 100 boxes, quantiles generalize the concept to an infinite number
of boxes and thus to arbitrary real numbers $\tau$ between 0.0 and 1.0, where 0.0 represents the
minimum value, 0.5 the median and 1.0 the maximum value. Quantiles are closely related to
the cumulative distribution function of the sample distribution.
`Statistics.Quantile(data, tau)`
`Statistics.QuantileFunc(data)`
`SortedArrayStatistics.Quantile(data, tau)`
`ArrayStatistics.QuantileInplace(data, tau)`
#### Quantile Conventions and Compatibility
Remember that all these descriptive statistics do not *compute* but merely *estimate*
statistical indicators of the value distribution. In the case of quantiles,
there is usually not a single number between the two groups specified by $\tau$.
There are multiple ways to deal with this: the SAS package defined at least 5 ways,
the R project supports 9 variants and Mathematican and SciPy have their own way
to parametrize the behavior.
The `QuantileCustom` functions support all 9 modes from the R-project, which includes the one
used by Microsoft Excel, and also the 4-parameter veriant of Mathematica: