Skip to content Skip to navigation

OpenStax-CNX

You are here: Home » Content » The Quantile Function

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • Rice Digital Scholarship

    This module is included in aLens by: Digital Scholarship at Rice UniversityAs a part of collection: "Applied Probability"

    Click the "Rice Digital Scholarship" link to see all content affiliated with them.

Also in these lenses

  • UniqU content

    This module is included inLens: UniqU's lens
    By: UniqU, LLCAs a part of collection: "Applied Probability"

    Click the "UniqU content" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.
 

The Quantile Function

Module by: Paul E Pfeiffer. E-mail the author

Summary: If F is a probability distribution function, the associated quantile function Q is essentially an inverse of F. The quantile function is defined on the unit interval (0,1). For F continuous and strictly increasing at t, then Q(u)=t iff F(t)=u. Thus, if u is a probability value, t=Q(u) is the value of t for which P(X≤t)=u. As an application, one may generate independent classes with prescribed distributions. Matlab procedures are developed for a variety of problems involving quantile functions.

The Quantile Function

The quantile function for a probability distribution has many uses in both the theory and application of probability. If F is a probability distribution function, the quantile function may be used to “construct” a random variable having F as its distributions function. This fact serves as the basis of a method of simulating the “sampling” from an arbitrary distribution with the aid of a random number generator. Also, given any finite class

{Xi:1in}{Xi:1in} of random variables, an independent class {Yi:1in}{Yi:1in} may be constructed, with each Xi and associated Yi having the same (marginal) distribution. Quantile functions for simple random variables may be used to obtain an important Poisson approximation theorem (which we do not develop in this work). The quantile function is used to derive a number of useful special forms for mathematical expectation.

General concept—properties, and examples

If F is a probability distribution function, the associated quantile function Q is essentially an inverse of F. The quantile function is defined on the unit interval (0,1)(0,1). For F continuous and strictly increasing at t, then Q(u)=tQ(u)=t iff F(t)=uF(t)=u. Thus, if u is a probability value, t=Q(u)t=Q(u) is the value of t for which P(Xt)=uP(Xt)=u.

Example 1: The Weibull distribution (3,2,0)(3,2,0)

u = F ( t ) = 1 - e - 3 t 2 t 0 t = Q ( u ) = - ln ( 1 - u ) / 3 u = F ( t ) = 1 - e - 3 t 2 t 0 t = Q ( u ) = - ln ( 1 - u ) / 3
(1)

Example 2: The Normal Distribution

The m-function norminv, based on the MATLAB function erfinv (inverse error function), calculates values of Q for the normal distribution.

The restriction to the continuous case is not essential. We consider a general definition which applies to any probability distribution function.

Definition: If F is a function having the properties of a probability distribution function, then the quantile function for F is given by

Q ( u ) = inf { t : F ( t ) u } u ( 0 , 1 ) Q ( u ) = inf { t : F ( t ) u } u ( 0 , 1 )
(2)

We note

  • If F(t*)u*F(t*)u*, then t*inf{t:F(t)u*}=Q(u*)t*inf{t:F(t)u*}=Q(u*)
  • If F(t*)<u*F(t*)<u*, then t*<inf{t:F(t)u*}=Q(u*)t*<inf{t:F(t)u*}=Q(u*)

Hence, we have the important property:

(Q1)Q(u)tQ(u)t iff uF(t)u(0,1)uF(t)u(0,1).

The property (Q1) implies the following important property:

(Q2)If UU uniform (0,1)(0,1), then X=Q(U)X=Q(U) has distribution function FX=FFX=F. To see this, note that FX(t)=P[Q(U)t]=P[UF(t)]=F(t)FX(t)=P[Q(U)t]=P[UF(t)]=F(t).

Property (Q2) implies that if F is any distribution function, with quantile function Q, then the random variable X=Q(U)X=Q(U), with U uniformly distributed on (0,1)(0,1), has distribution function F.

Example 3: Independent classes with prescribed distributions

Suppose {Xi:1in}{Xi:1in} is an arbitrary class of random variables with corresponding distribution functions {Fi:1in}{Fi:1in}. Let {Qi:1in}{Qi:1in} be the respective quantile functions. There is always an independent class {Ui:1in}{Ui:1in} iid uniform (0,1)(0,1) (marginals for the joint uniform distribution on the unit hypercube with sides (0,1)(0,1)). Then the random variables Yi=Qi(Ui),1inYi=Qi(Ui),1in, form an independent class with the same marginals as the Xi.

Several other important properties of the quantile function may be established.

Figure 1: Graph of quantile function from graph of distribution function,
Figure 1 consists of three graphs. The first is a plot of U = F(t) with t on the horizontal axis, and u on the vertical axis. The plotted curve begins at the point (-1, 0), and increases at a constant slope until t=1. The curve then increases exponentially, beginning with a very shallow slope and increasing in slope to be nearly vertical. At t=3, the curve is cut short and a horizontal line continues to t=4. The horizontal segment is met with a vertical line segment until the curve reaches u=1, at which it again continues horizontally to the right. The second graph is identical in shape to the first graph, except that the graph moves in the downward instead of upward. The third graph plots u on the horizontal axis and t on the vertical axis, plotting t = Q(u). The curve is identical to the curve in the first graph, except with the adjusted axes, the curve is rotated 90 degrees counter-clockwise. There is also a vertical dashed line along u=1 that meets the curve at its rightmost segment.
  1. Q is left-continuous, whereas F is right-continuous.
  2. If jumps are represented by vertical line segments, construction of the graph of u=Q(t)u=Q(t) may be obtained by the following two step procedure:
    • Invert the entire figure (including axes), then
    • Rotate the resulting figure 90 degrees counterclockwise
    This is illustrated in Figure 1. If jumps are represented by vertical line segments, then jumps go into flat segments and flat segments go into vertical segments.
  3. If X is discrete with probability pi at ti,1inti,1in, then F has jumps in the amount pi at each ti and is constant between. The quantile function is a left-continuous step function having value ti on the interval (bi-1,bi](bi-1,bi], where b0=0b0=0 and bi=j=1ipjbi=j=1ipj. This may be stated
    IfF(ti)=bi,thenQ(u)=tiforF(ti-1)<uF(ti)IfF(ti)=bi,thenQ(u)=tiforF(ti-1)<uF(ti)
    (3)

Example 4: Quantile function for a simple random variable

Suppose simple random variable X has distribution

X = [ - 2 0 1 3 ] P X = [ 0 . 2 0 . 1 0 . 3 0 . 4 ] X = [ - 2 0 1 3 ] P X = [ 0 . 2 0 . 1 0 . 3 0 . 4 ]
(4)

Figure 1 shows a plot of the distribution function FX. It is reflected in the horizontal axis then rotated counterclockwise to give the graph of Q(u)Q(u) versus u.

Figure 2: Distribution and quantile functions for Example 4.
Figure 2 consists of two graphs. The first is a plot of U = F(t) graphed with t as the horizontal axis and u as the vertical axis, starting at (-2, 0) with a small vertical segment that meets a black dot at a right angle. Continuing to the right, the line after the black dot is drawn to the vertical axis, with the number 0.2 labeled above the horizontal segment. At the vertical axis a small vertical line along the axis continues to another black dot on the vertical axis. After the black dot towards the right is another horizontal line with the number 0.3 labeled above the segment. At t=1, the horizontal segment ends, then moving vertically to a third black dot. The next segment of the plot is horizontal, extending from t=1 to t-3, labeled as 0.6. At t=3 the plot moves vertically to a fourth black dot at point (3, 1). The segment after the black dot moves horizontally to the right edge of the graph, labeled as 1. The second graph is a plot of t = Q(u), with u as the horizontal axis and t as the vertical axis. The plot is identical in shape to the plot in the first graph of figure 2 except rotated in the fashion as the axes.

We use the analytic characterization above in developing a number of m-functions and m-procedures.

m-procedures for a simple random variable

The basis for quantile function calculations for a simple random variable is the formula above. This is implemented in the m-function dquant, which is used as an element of several simulation procedures. To plot the quantile function, we use dquanplot which employs the stairs function and plots X vs the distribution function FXFX. The procedure dsample employs dquant to obtain a “sample” from a population with simple distribution and to calculate relative frequencies of the various values.

Example 5: Simple Random Variable

X =  [-2.3 -1.1 3.3 5.4 7.1 9.8];
PX = 0.01*[18 15 23 19 13 12];
dquanplot
Enter VALUES for X  X
Enter PROBABILITIES for X  PX     % See Figure 3 for plot of results
rand('seed',0)                 % Reset random number generator for reference
dsample
Enter row matrix of values  X
Enter row matrix of probabilities  PX
Sample size n  10000
    Value      Prob    Rel freq
   -2.3000    0.1800    0.1805
   -1.1000    0.1500    0.1466
    3.3000    0.2300    0.2320
    5.4000    0.1900    0.1875
    7.1000    0.1300    0.1333
    9.8000    0.1200    0.1201
Sample average ex = 3.325
Population mean E[X] = 3.305
Sample variance = 16.32
Population variance Var[X] = 16.33
Figure 3: Quantile function for Example 5.
Figure three is a plot of a quantile function on a square gridded graph. The plot looks like a set of stairs, moving from the bottom-left to the top-right of the figure. The vertical axis is t = Q(u), and the horizontal axis is u. the graph begins just below -2 on the vertical axis, and moves horizontally to just before 0.2, where the plot continues after a small blue circle at the vertex with a vertical line extending upward to approximately -1. At this point, the plot then moves right, horizontally, to approximately u=0.33. There is another small blue circle at this vertex, and then the plot continues vertically for a longer segment to approximately 3.5. The plot continues horizontally to the right after this point to approximately u=0.57. At this point, there is a third small blue circle marking the vertex, and then the plot continues vertically upward to approximately 5.5. The plot continues horizontally to the right after this point to approximately u=0.75 where it is met with a fourth small blue circle. The plot moves upward after this point to 7, and then moves to the right to u=0.88. One more vertical segment follows after another small blue circle nearly to 10, where it finally moves to the right to u=1 and is met with a sixth blue circle.

Sometimes it is desirable to know how many trials are required to reach a certain value, or one of a set of values. A pair of m-procedures are available for simulation of that problem. The first is called targetset. It calls for the population distribution and then for the designation of a “target set” of possible values. The second procedure, targetrun, calls for the number of repetitions of the experiment, and asks for the number of members of the target set to be reached. After the runs are made, various statistics on the runs are calculated and displayed.

Example 6

X = [-1.3 0.2 3.7 5.5 7.3];     % Population values
PX = [0.2 0.1 0.3 0.3 0.1];     % Population probabilities
E = [-1.3 3.7];                 % Set of target states
targetset
Enter population VALUES  X
Enter population PROBABILITIES  PX
The set of population values is
   -1.3000    0.2000    3.7000    5.5000    7.3000
Enter the set of target values  E
Call for targetrun
rand('seed',0)                  % Seed set for possible comparison
targetrun
Enter the number of repetitions  1000
The target set is
   -1.3000    3.7000
Enter the number of target values to visit  2
The average completion time is 6.32
The standard deviation is 4.089
The minimum completion time is 2
The maximum completion time is 30
To view a detailed count, call for D.
The first column shows the various completion times;
the second column shows the numbers of trials yielding those times
% Figure 10.6.4 shows the fraction of runs requiring t steps or less
Figure 4: Fraction of runs requiring t steps or less.
Figure four is a fraction of Runs t steps or less. The horizontal axis is t, which is the number of steps to complete the run, and the vertical axis is the fraction of runs. The plot begins from the bottom left with a strong positive slope, and as it moves to the right, the slope becomes more shallow until, at a value of 1 on the horizontal axis, the plot is nearly horizontal, where it terminates exactly at the top-right point on the graph.

m-procedures for distribution functions

A procedure dfsetup utilizes the distribution function to set up an approximate simple distribution. The m-procedure quanplot is used to plot the quantile function. This procedure is essentially the same as dquanplot, except the ordinary plot function is used in the continuous case whereas the plotting function stairs is used in the discrete case. The m-procedure qsample is used to obtain a sample from the population. Since there are so many possible values, these are not displayed as in the discrete case.

Example 7: Quantile function associated with a distribution function.

F = '0.4*(t + 1).*(t < 0) + (0.6 + 0.4*t).*(t >= 0)';  % String
dfsetup
Distribution function F is entered as a string
variable, either defined previously or upon call
Enter matrix [a b] of X-range endpoints  [-1 1]
Enter number of X approximation points  1000
Enter distribution function F as function of t  F
Distribution is in row matrices X and PX
quanplot
Enter row matrix of values  X
Enter row matrix of probabilities  PX
Probability increment h  0.01          % See Figure 5 for plot
qsample
Enter row matrix of X values  X
Enter row matrix of X probabilities  PX
Sample size n  1000
Sample average ex = -0.004146
Approximate population mean E(X) = -0.0004002     % Theoretical = 0
Sample variance vx = 0.25
Approximate population variance V(X) = 0.2664
Figure 5: Quantile function for Example 7.
Figure five is a plot of the quantile function for example 7. The horizontal axis is labeled u, and the vertical axis is t = Q(u). The plot on the graph begins at the bottom right corner, with the vertical value of -1 and the horizontal value of 0. The plot has a constant positive slope to (0.4, 0), where it extends horizontally to (0.6, 0). Then, the plot continues with the same positive slope as the first segment, where it terminates at (1, 1).

m-procedures for density functions

An m- procedure acsetup is used to obtain the simple approximate distribution. This is essentially the same as the procedure tuappr, except that the density function is entered as a string variable. Then the procedures quanplot and qsample are used as in the case of distribution functions.

Example 8: Quantile function associated with a density function.

acsetup
Density f is entered as a string variable.
either defined previously or upon call.
Enter matrix [a b] of x-range endpoints  [0 3]
Enter number of x approximation points  1000
Enter density as a function of t  '(t.^2).*(t<1) + (1- t/3).*(1<=t)'
Distribution is in row matrices X and PX
quanplot
Enter row matrix of values  X
Enter row matrix of probabilities  PX
Probability increment h  0.01               % See Figure 6 for plot
rand('seed',0)
qsample
Enter row matrix of values  X
Enter row matrix of probabilities  PX
Sample size n  1000
Sample average ex = 1.352
Approximate population mean E(X) = 1.361  % Theoretical = 49/36 = 1.3622
Sample variance vx = 0.3242
Approximate population variance V(X) = 0.3474    % Theoretical = 0.3474
Figure 6: Quantile function for Example 8.
Figure six is a plot of the quantile function for example 8. The horizontal axis is labeled u, and the vertical axis is t = Q(u). The plot on the graph begins at the bottom-right at (0, 0) with a very steep positive slope. The plot's slope quickly decreases to a shallow positive slope. The plot increases  across the graph, and about halfway across the page the slope begins to progressively increase in the same form that it was previously decreasing, until it terminates at (1, 3) at a very strong (nearly vertical) positive slope.

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks