OrderStatistic - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Statistics

  

OrderStatistic

  

compute order statistics

 

Calling Sequence

Parameters

Description

Computation

Data Set Options

Random Variable Options

Examples

References

Compatibility

Calling Sequence

OrderStatistic(A, j, ds_options)

OrderStatistic(X, j, n, rv_options)

Parameters

A

-

data sample

X

-

algebraic; random variable or distribution

j

-

integer; order

n

-

posint; sample size

ds_options

-

(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

rv_options

-

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

Description

• 

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.

Computation

• 

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 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[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.

Examples

withStatistics:

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

XOrderStatisticNormal5,2,2,10:

MeanX

45_t2ⅇ_t5281+erf_t5241+erf_t52481024πⅆ_t

(1)

MeanX,numeric

2.997285906

(2)

plotPDFX,t,t=0..10

Now try the second from the right.

YOrderStatisticNormal5,2,2,10:

MeanY,numeric

7.002714090

(3)

The following input is invalid.

ZOrderStatisticNormal5,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.

ASampleNormal5,2,105:

OrderStatisticA,2

−3.40601157648346

(4)

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].

A1..10

5.340716842820827.012956817503625.537425358316622.068039106082454.928484292321014.986993273074734.885633995533524.630799810750145.407710804742224.80225635194575

(5)

OrderStatisticA,2,inplace=true

−3.40601157648346

(6)

A1..10

−5.02374426654846−3.40601157648346−3.25835036249453−3.23402927603729−2.55397727446371−2.14359446638416−3.07461394713608−1.97207576720959−2.74110950442011−2.38511709696444

(7)

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

quotationThe Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform.

quotationThe Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform.

(8)

wordsremovetype,StringTools:-Splitquotation, .,

wordsThe,Analytical,Engine,has,no,pretensions,whatever,to,originate,anything,It,can,do,whatever,we,know,how,to,order,it,to,perform

(9)

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

compare_lengthprocx&comma;yreturnlengthx<lengthyend proc

(10)

OrderStatisticwords&comma;14&comma;ordering=compare_length

order

(11)

References

  

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

Compatibility

• 

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.

See Also

Statistics

Statistics/Computation

Statistics/DescriptiveStatistics

Statistics/RandomVariables

Statistics[Distributions]