Statistics
Quantile
compute quantiles
Calling Sequence
Parameters
Description
Computation
Data Set Options
Random Variable Options
Examples
References
Compatibility
Quantile(A, p, ds_options)
Quantile(X, p, rv_options)
A
-
data set or Matrix data set
X
algebraic; random variable or distribution
p
algebraic; probability
ds_options
(optional) equation(s) of the form option=value where option is one of ignore, method, or weights; specify options for computing the quantile of a data set
rv_options
(optional) equation of the form numeric=value; specifies options for computing the quantile of a random variable
The Quantile function computes the quantile corresponding to the given probability p for the specified random variable or data set.
For a real valued random variable X with distribution function F⁡x, and any p between 0 and 1, the pth quantile of X is defined as inf⁢{y⁢|⁢Fy⁢≥⁢p}. For continuous random variables this is equivalent to the inverse distribution function.
For more details on sample quantiles see option method below.
The first parameter can be a data set (e.g., a Vector), a Matrix data set, a distribution (see Statistics[Distribution]), a random variable, or an algebraic expression involving random variables (see Statistics[RandomVariable]).
The second parameter p is the probability.
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.
By default, all computations involving random variables are performed symbolically (see option numeric below).
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 Quantile command. Missing items are represented by undefined or Float(undefined). If ignore=false and A contains missing data, the missing data elements will be considered greater than all present data points. If ignore=true all missing items in A will be ignored. The default value is false.
weights=Vector -- Data weights. The number of elements in the weights array must be equal to the number of elements in the original data sample. By default all elements in A are assigned weight 1.
method=integer[1..9] -- Method for calculating the quantiles. Let n denote the number of non-missing elements in A and for i=1..n let Bi denotes the ith order statistic of A. The first two methods for calculating quantiles are defined as follows.
Bj, where j=n⁢p+1;
Bj, where j=n⁢p+12;
Bj, where j=n⁢p+1; unless n⁢p+1 is an integer, in which case the result is Bj−12+Bj2.
Note that p is converted to a (hardware or software) floating point value before j is computed, which may cause surprising results due to roundoff.
The remaining quantiles are calculated in the form Bj+Bj+1−Bj⁢r, where j=q, r=frac⁡q, and q is one of the quantities given below.
q=n⁢p;
q=n⁢p+12;
q=n+1⁢p;
q=1+n−1⁢p;
q=13+n+13⁢p; (default method)
q=38+n+14⁢p.
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 quantile is computed using exact arithmetic. To compute the quantile numerically, specify the numeric or numeric = true option.
with⁡Statistics:
Compute the quantile of the Weibull distribution with parameters a and b.
Quantile⁡Weibull⁡a,b,13
a⁢ln⁡321b
Use numeric parameters.
Quantile⁡Weibull⁡3,5,13
3⁢ln⁡3215
Quantile⁡Weibull⁡3,5,0.3333333333
2.50444761563527
Quantile⁡Weibull⁡3,5,13,numeric
Generate a random sample of size 100000 drawn from the above distribution and compute the sample quantile.
A≔Sample⁡Weibull⁡3,5,105:
Quantile⁡A,13
2.50274848246744
Compute the standard error of the sample quantile for the normal distribution with parameters 5 and 2.
X≔Normal⁡5,2
B≔Sample⁡X,106:
Quantile⁡X,13,numeric,StandardError106⁡Quantile,X,13,numeric
4.13854540122573,0.00259298577070808
Quantile⁡B,13
4.13691708812173
Create two normal random variables and compute the quantiles of their sum.
X≔RandomVariable⁡Normal⁡5,2:
Y≔RandomVariable⁡Normal⁡2,5:
Quantile⁡X+Y,13
7⁢58+58⁢RootOf⁡3⁢erf⁡_Z+1⁢5858
Quantile⁡X+Y,13,numeric
4.68046250585916
Verify this using simulation.
C≔Sample⁡X+Y,106:
Quantile⁡C,13
4.68145838350636
Compute the quantile of a weighted data set.
V≔seq⁡i,i=57..77,undefined:
W≔2,4,14,41,83,169,394,669,990,1223,1329,1230,1063,646,392,202,79,32,16,5,2,5:
Quantile⁡V,13,weights=W
65.5485434888542
Quantile⁡V,13,weights=W,ignore=true
65.5538510125591
Consider the following Matrix data set.
M≔Matrix⁡3,1130,114694,4,1527,127368,3,907,88464,2,878,96484,4,995,128007
M≔31130114694415271273683907884642878964844995128007
We compute the 37 quantile of each of the columns.
Quantile⁡M,37
3.961.476190476190107756.857142857
Stuart, Alan, and Ord, Keith. Kendall's Advanced Theory of Statistics. 6th ed. London: Edward Arnold, 1998. Vol. 1: Distribution Theory.
Hyndman, R.J., and Fan, Y. "Sample Quantiles in Statistical Packages." American Statistician, Vol. 50. (1996): 361-365.
The A parameter was updated in Maple 16.
See Also
Statistics[Computation]
Statistics[CumulativeDistributionFunction]
Statistics[Decile]
Statistics[DescriptiveStatistics]
Statistics[Distributions]
Statistics[ExpectedValue]
Statistics[Percentile]
Statistics[Quartile]
Statistics[RandomVariables]
Statistics[StandardError]
Download Help Document