Student[Statistics] - Maple Programming Help

Home : Support : Online Help : Education : Student Packages : Statistics : Student/Statistics/Median

Student[Statistics]

 Median
 compute the median

 Calling Sequence Median(A, numeric_options, output_option) Median(M, numeric_options, output_option) Median(X, numeric_options, output_option)

Parameters

 A - M - X - algebraic; random variable numeric_option - (optional) equation of the form numeric=value where value is true or false output_option - (optional) equation of the form output=x where x is value, plot, or both

Description

 • The Median function computes the median of the specified random variable or data sample.
 • The first parameter can be a Vector, a list, a Matrix, a random variable, or an algebraic expression involving random variables (see Student[Statistics][RandomVariable]).
 • In the first calling sequence, if A has an even number of data points, then the median is the mean of the two middle data points.
 • In the second calling sequence, if X is a discrete random variable, then the median is defined as the first point $t$ such that the CDF at t is greater than or equal to $\frac{1}{2}$.
 • If the option output is not included or is specified to be output=value, then the function will return the value of the mean. If output=plot is specified, then the function will return a plot of the input data set and its mean. If output=both is specified, then both the value and the plot of the mean will be returned.

Computation

 • By default, all computations involving random variables are performed symbolically (see option numeric below).
 • If the median is determined by only one data point in the data set, then the median equals that data point.
 • If the median is determined by two data points in the data set, and at least one of them has floating point values or the option numeric is included , then the computation is done in floating point. Otherwise the computation is exact.
 • By default, the median is computed according to the rules mentioned above. To always compute the median numerically, specify the numeric or numeric = true option.

Examples

 > $\mathrm{with}\left(\mathrm{Student}\left[\mathrm{Statistics}\right]\right):$

Compute the median of the Normal distribution with parameters $p$ and $q$.

 > $\mathrm{Median}\left(\mathrm{NormalRandomVariable}\left(p,q\right)\right)$
 ${p}$ (1)

Use numeric parameters.

 > $\mathrm{Median}\left(\mathrm{NormalRandomVariable}\left(3,5\right)\right)$
 ${3}$ (2)
 > $\mathrm{Median}\left(\mathrm{NormalRandomVariable}\left(\mathrm{\pi },5\right),\mathrm{numeric}\right)$
 ${3.141592654}$ (3)

If the output=plot option is included, then a plot will be returned.

 > $\mathrm{Median}\left(\mathrm{NormalRandomVariable}\left(\mathrm{\pi },5\right),\mathrm{numeric},\mathrm{output}=\mathrm{plot}\right)$

Compute the median of the given data. Since $\mathrm{\pi }$ and $4$ are the numbers that are eventually used to compute the median, and they are both exact values (not using floating point values), the result is an exact expression.

 > $\mathrm{Median}\left(\mathrm{Vector}\left[\mathrm{row}\right]\left(\left[\mathrm{\pi },1,4,6.01\right]\right)\right)$
 $\frac{{\mathrm{\pi }}}{{2}}{+}{2}$ (4)

Compute the median of the given data. Since $\frac{26}{3}$ and $22.0$ are the numbers that are eventually used to compute the median, and $22.0$ is a floating point value, the result will be a floating point value.

 > $\mathrm{Median}\left(\left[34.2,22.0,2,\frac{26}{3}\right]\right)$
 ${15.33333333}$ (5)

If the output=both option is included, then both the value of the median and its plot will be returned.

 > $\mathrm{median},\mathrm{graph}≔\mathrm{Median}\left(\left[34.2,22.0,2,\frac{26}{3}\right],\mathrm{output}=\mathrm{both}\right)$
 ${\mathrm{median}}{,}{\mathrm{graph}}{≔}{15.33333333}{,}{\mathrm{PLOT}}{}\left({\mathrm{...}}\right)$ (6)
 > $\mathrm{median}$
 ${15.33333333}$ (7)
 > $\mathrm{graph}$

Consider the following Matrix data sample.

 > $M≔\mathrm{Matrix}\left(\left[\left[3,5.0,\mathrm{ln}\left(300\right),3\right],\left[2,2\mathrm{\pi },9,3\right],\left[1,\mathrm{sqrt}\left(26\right),4,3.0\right],\left[5,7,7.0,3\right]\right]\right)$
 ${M}{≔}\left[\begin{array}{cccc}{3}& {5.0}& {\mathrm{ln}}{}\left({300}\right)& {3}\\ {2}& {2}{}{\mathrm{\pi }}& {9}& {3}\\ {1}& \sqrt{{26}}& {4}& {3.0}\\ {5}& {7}& {7.0}& {3}\end{array}\right]$ (8)

Compute the median of each of the columns according to the computation rules.

 > $\mathrm{Median}\left(M\right)$
 $\left[\begin{array}{cccc}\frac{{5}}{{2}}& \frac{\sqrt{{26}}}{{2}}{+}{\mathrm{\pi }}& {6.351891238}& {3.000000000}\end{array}\right]$ (9)

References

 Stuart, Alan, and Ord, Keith. Kendall's Advanced Theory of Statistics. 6th ed. London: Edward Arnold, 1998. Vol. 1: Distribution Theory.

Compatibility

 • The Student[Statistics][Median] command was introduced in Maple 18.
 • For more information on Maple 18 changes, see Updates in Maple 18.