compute order statistics - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Statistics : Statistics Package : Quantities : Statistics/OrderStatistic

Statistics[OrderStatistic] - compute order statistics

Calling Sequence

OrderStatistic(A, j, ds_options)

OrderStatistic(X, j, n, rv_options)




data sample



algebraic; random variable or distribution



integer; order



posint; sample size



(optional) equation(s) of the form option=value where option is one of ignore, inplace, or ordering; specify options for computing an OrderStatistic of a data set



(optional) equation of the form numeric=value; specifies options for computing an OrderStatistic of a random variable



For a data set A the OrderStatistic function computes the jth order statistic of A. For a random variable X, the OrderStatistic commands returns a new random variable which has the same distribution as the jth order statistic of an n-element sample drawn from the same distribution as X. This new random variable is independent of other random variables, including random variables created by other calls to OrderStatistic.


The first parameter can be a data set (given as e.g. a Vector), a distribution (see Statistics[Distribution]), a random variable, or an algebraic expression involving random variables (see Statistics/RandomVariable).


The second parameter j is the order. If j is a negative integer, then the n+j+1th order statistic is calculated.


If the first parameter is a random variable or a distribution, the third parameter specifies the sample size.



By default, all computations involving random variables are performed symbolically (see option numeric below).


All computations involving data are performed in floating-point; therefore, all data provided must have type realcons and all returned solutions are floating-point, even if the problem is specified with exact values.


For more information about computation in the Statistics package, see the Statistics/Computation help page.

Data Set Options


The ds_options argument can contain one or more of the options shown below. More information for some options is available in the Statistics/DescriptiveStatistics help page.


ignore=truefalse -- This option controls how missing data is handled by the OrderStatistic command. Missing items are represented by undefined or Float(undefined). So, if ignore=false and A contains missing data, the OrderStatistic command can behave in an unexpected manner. If ignore=true all missing items in A will be considered greater than all other data; that is, they become higher order statistics. The default value is false.


inplace=truefalse -- In order to compute an order statistic of a data set, Maple normally makes a copy of that data set and rearranges the items to make it, in some sense, closer to being sorted. (In particular, when it computes the jth order statistic, then all elements before the jth element of this copy of A will be less than or equal to A[j], and all elements after it will be greater or equal). If A has the correct data type (details mentioned later), the ignore option is false (or not included), and the inplace option is set to true, then Maple will not make this copy and apply the reordering to A itself. If A does not have the appropriate data type, or the ignore option is specified, then the inplace option is ignored.


The data sample A can use the inplace option if it is a Vector or a 1-dimensional Array, and it has its datatype option set to float. More precisely, if the setting of the Digits variable is less than or equal to evalhf(Digits) (this is the default), then its datatype option needs to be float[8]; otherwise it needs to be sfloat. This is the setting you get when you specify the option datatype=float to the Vector or Array procedure.


ordering=procedure -- By default, OrderStatistic will deal only with numeric data, and it will compute the jth order statistic according to the numeric ordering. If you need the jth order statistic according to a different ordering, you can get it by specifying an ordering procedure using the ordering=p option. The procedure p will be called with two arguments, say p(x, y), and it should return true if and only if x must precede y in the desired ordering, and false otherwise -- that is, p should represent a strict ordering.

Random Variable Options


The rv_options argument can contain one or more of the options shown below. More information for some options is available in the Statistics/RandomVariables help page.


numeric=truefalse -- By default, the order statistic is defined using exact arithmetic. To define the order statistic numerically, specify the numeric or numeric = true option.



Compute the second order statistic of a 10-element sample drawn from the normal distribution with parameters 5 and 2.









Now try the second from the right.





The following input is invalid.


Error, (in Statistics:-OrderStatistic) index out of range: 11

Generate a random sample of size 100000 drawn from the above distribution and compute the second order statistic.





The Vector returned by Sample has a suitable data type for using the inplace option. The previous call did not use the inplace option, so the elements in A are currently unsorted. After calling OrderStatistic, the second order statistic will be in A[2].










To get the fourteenth shortest word from a quotation, you can separate it into words and then use OrderStatistic with a custom ordering function.

quotation:=The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform.

quotation:=The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform.


words:=removetype,StringTools:-Splitquotation, .,



compare_length := proc(x, y) return length(x) < length(y); end proc;

compare_length:=procx&comma;yreturnlengthx<lengthyend proc





See Also

Statistics, Statistics/Computation, Statistics/DescriptiveStatistics, Statistics/RandomVariables, Statistics[Distributions]



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

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam