compute order statistics
Data Set Options
Random Variable Options
OrderStatistic(A, j, ds_options)
OrderStatistic(X, j, n, rv_options)
algebraic; random variable or distribution
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.
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 one-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; 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.
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.
X := OrderStatistic(Normal(5, 2), 2, 10):
plot(PDF(X, t), t = 0..10);
Now try the second from the right.
Y := OrderStatistic(Normal(5, 2), -2, 10):
The following input is invalid.
Z := OrderStatistic(Normal(5, 2), 11, 10):
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.
A := Sample(Normal(5, 2), 10^5):
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.
OrderStatistic(A, 2, inplace = true);
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 := remove(type, StringTools:-Split(quotation, " ."), "");
compare_length := proc(x, y) return length(x) < length(y); end proc;
OrderStatistic(words, 14, ordering = compare_length);
Stuart, Alan, and Ord, Keith. Kendall's Advanced Theory of Statistics. 6th ed. London: Edward Arnold, 1998. Vol. 1: Distribution Theory.
The Statistics[OrderStatistic] command was updated in Maple 2015.
The inplace option was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
Download Help Document
What kind of issue would you like to report? (Optional)