Statistics - Maple Help

Statistics

 Rank
 rank data items according to their numeric values

 Calling Sequence Rank(X, options)

Parameters

 X - options - (optional) equation(s) of the form option=value where option is one of order or output; specify options for the Rank function

Description

 • For a data set X of size n, the Rank command ranks the elements of X according to their floating-point values.
 • By default, an array of ranks is returned, that is an array of distinct integers between 1 and n. By default the elements of X are ranks in the ascending order. Note that if i is different from j then ${\mathrm{data}}_{i}$ and ${\mathrm{data}}_{j}$ will receive distinct ranks even if data[i] = data[j].
 • The first parameter X is the data set - given as e.g. a Vector.

Options

 The options argument can contain one or more of the options shown below.
 • order=ascending or descending -- Indicate whether the elements of X should be ranked in the ascending or descending order. The default value is order=ascending.
 • output=table -- By default (output=rtable) different elements of X receive different ranks even if the two elements have the same numeric value. If this option is set to output=table then the elements of X will be ranked according to their position in the sorted sample with all multiple occurrences removed.

Notes

 • Each element of X can be any Maple expression, but this expression must be able to be evaluated to a floating-point number. Failure to evaluate to do so will generate an exception.
 • If the output option is set to output=table all elements in X must be of type numeric.
 • The Rank command leaves the original data set X unchanged.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔\mathrm{Array}\left(\left[0.5,0.7,0.5,0.1,0.3,0.1,0.2,0.1\right]\right)$
 ${A}{:=}\left[\begin{array}{cccccccc}{0.5}& {0.7}& {0.5}& {0.1}& {0.3}& {0.1}& {0.2}& {0.1}\end{array}\right]$ (1)

Rank the elements of A in the ascending order.

 > $R≔\mathrm{Rank}\left(A\right)$
 ${R}{:=}\left[\begin{array}{cccccccc}{6}& {8}& {7}& {1}& {5}& {2}& {4}& {3}\end{array}\right]$ (2)

Reorder the elements of A according to their ranks.

 > $B≔\mathrm{OrderByRank}\left(A,R\right)$
 ${B}{:=}\left[\begin{array}{cccccccc}{0.1}& {0.1}& {0.1}& {0.2}& {0.3}& {0.5}& {0.5}& {0.7}\end{array}\right]$ (3)

Reorder the elements of A in the descending order.

 > $Q≔\mathrm{Rank}\left(A,\mathrm{order}=\mathrm{descending}\right)$
 ${Q}{:=}\left[\begin{array}{cccccccc}{2}& {1}& {3}& {6}& {4}& {7}& {5}& {8}\end{array}\right]$ (4)
 > $C≔\mathrm{OrderByRank}\left(A,Q\right)$
 ${C}{:=}\left[\begin{array}{cccccccc}{0.7}& {0.5}& {0.5}& {0.3}& {0.2}& {0.1}& {0.1}& {0.1}\end{array}\right]$ (5)

Build the ranks table.

 > $T≔\mathrm{Rank}\left(A,\mathrm{output}=\mathrm{table}\right)$
 ${T}{:=}{\mathrm{table}}\left(\left[{0.2}{=}{2}{,}{0.1}{=}{1}{,}{0.5}{=}{4}{,}{0.7}{=}{5}{,}{0.3}{=}{3}\right]\right)$ (6)
 > ${A}_{4},{T}_{{A}_{4}}$
 ${0.1}{,}{1}$ (7)
 > ${A}_{1},{T}_{{A}_{1}}$
 ${0.5}{,}{4}$ (8)