



In statistics, aQ–Q plot (quantile–quantile plot) is a probability plot, agraphical method for comparing twoprobability distributions by plotting theirquantiles against each other.[1] A point(x,y) on the plot corresponds to one of the quantiles of the second distribution (y-coordinate) plotted against the same quantile of the first distribution (x-coordinate). This defines aparametric curve where the parameter is the index of the quantile interval.
If the two distributions being compared are similar, the points in the Q–Q plot will approximately lie on theidentity liney =x. If the distributions are linearly related, the points in the Q–Q plot will approximately lie on a line, but not necessarily on the liney =x. Q–Q plots can also be used as a graphical means of estimating parameters in alocation-scale family of distributions.
A Q–Q plot is used to compare the shapes of distributions, providing a graphical view of how properties such aslocation,scale, andskewness are similar or different in the two distributions. Q–Q plots can be used to compare collections of data, ortheoretical distributions. The use of Q–Q plots to compare two samples of data can be viewed as anon-parametric approach to comparing their underlying distributions. A Q–Q plot is generally more diagnostic than comparing the samples'histograms, but is less widely known. Q–Q plots are commonly used to compare a data set to a theoretical model.[2][3] This can provide an assessment ofgoodness of fit that is graphical, rather than reducing to a numericalsummary statistic. Q–Q plots are also used to compare two theoretical distributions to each other.[4] Since Q–Q plots compare distributions, there is no need for the values to be observed as pairs, as in ascatter plot, or even for the numbers of values in the two groups being compared to be equal.
The term "probability plot" sometimes refers specifically to a Q–Q plot, sometimes to a more general class of plots, and sometimes to the less commonly usedP–P plot. Theprobability plot correlation coefficient plot (PPCC plot) is a quantity derived from the idea of Q–Q plots, which measures the agreement of a fitted distribution with observed data and which is sometimes used as a means of fitting a distribution to data.

A Q–Q plot is a plot of the quantiles of two distributions against each other, or a plot based on estimates of the quantiles. The pattern of points in the plot is used to compare the two distributions.
The main step in constructing a Q–Q plot is calculating or estimating the quantiles to be plotted. If one or both of the axes in a Q–Q plot is based on a theoretical distribution with a continuouscumulative distribution function (CDF), all quantiles are uniquely defined and can be obtained by inverting the CDF. If a theoretical probability distribution with a discontinuous CDF is one of the two distributions being compared, some of the quantiles may not be defined, so an interpolated quantile may be plotted. If the Q–Q plot is based on data, there are multiple quantile estimators in use. Rules for forming Q–Q plots when quantiles must be estimated or interpolated are calledplotting positions.
A simple case is where one has two data sets of the same size. In that case, to make the Q–Q plot, one orders each set in increasing order, then pairs off and plots the corresponding values. A more complicated construction is the case where two data sets of different sizes are being compared. To construct the Q–Q plot in this case, it is necessary to use aninterpolated quantile estimate so that quantiles corresponding to the same underlying probability can be constructed.
More abstractly,[4] given two cumulative probability distribution functionsF andG, with associatedquantile functionsF−1 andG−1 (the inverse function of the CDF is the quantile function), the Q–Q plot draws theq-th quantile ofF against theq-th quantile ofG for a range of values ofq. Thus, the Q–Q plot is aparametric curve indexed over [0,1] with values in the real planeR2.
Typically for an analysis of normality, the vertical axis shows the values of the variable of interest, sayx with CDFF(x), and the horizontal axis representsN−1(F(x)), whereN−1(.) represents the inverse cumulative normal distribution function.
The points plotted in a Q–Q plot are always non-decreasing when viewed from left to right. If the two distributions being compared are identical, the Q–Q plot follows the 45° liney =x. If the two distributions agree after linearly transforming the values in one of the distributions, then the Q–Q plot follows some line, but not necessarily the liney =x. If the general trend of the Q–Q plot is flatter than the liney =x, the distribution plotted on the horizontal axis is moredispersed than the distribution plotted on the vertical axis. Conversely, if the general trend of the Q–Q plot is steeper than the liney =x, the distribution plotted on the vertical axis is moredispersed than the distribution plotted on the horizontal axis. Q–Q plots are often arced, or S-shaped, indicating that one of the distributions is more skewed than the other, or that one of the distributions has heavier tails than the other.
Although a Q–Q plot is based on quantiles, in a standard Q–Q plot it is not possible to determine which point in the Q–Q plot determines a given quantile. For example, it is not possible to determine the median of either of the two distributions being compared by inspecting the Q–Q plot. Some Q–Q plots indicate the deciles to make determinations such as this possible.
The intercept and slope of a linear regression between the quantiles gives a measure of the relative location and relative scale of the samples. If the median of the distribution plotted on the horizontal axis is 0, the intercept of a regression line is a measure of location, and the slope is a measure of scale. The distance between medians is another measure of relative location reflected in a Q–Q plot. The "probability plot correlation coefficient" (PPCC plot) is thecorrelation coefficient between the paired sample quantiles. The closer the correlation coefficient is to one, the closer the distributions are to being shifted, scaled versions of each other. For distributions with a single shape parameter, the probability plot correlation coefficient plot provides a method for estimating the shape parameter – one simply computes the correlation coefficient for different values of the shape parameter, and uses the one with the best fit, just as if one were comparing distributions of different types.
Another common use of Q–Q plots is to compare the distribution of a sample to a theoretical distribution, such as the standardnormal distributionN(0,1), as in anormal probability plot. As in the case when comparing two samples of data, one orders the data (formally, computes the order statistics), then plots them against certain quantiles of the theoretical distribution.[3]
The choice of quantiles from a theoretical distribution can depend upon context and purpose. One choice, given a sample of sizen, isk /n fork = 1, …,n, as these are the quantiles that thesampling distribution realizes. The last of these,n /n, corresponds to the 100th percentile – the maximum value of the theoretical distribution, which is sometimes infinite. Other choices are the use of(k − 0.5) /n, or instead to space then points such that there is an equal distance between all of them and also between the two outermost points and the edges of the interval, usingk / (n + 1).[6]
Many other choices have been suggested, both formal and heuristic, based on theory or simulations relevant in context. The following subsections discuss some of these. A narrower question is choosing a maximum (estimation of a population maximum), known as theGerman tank problem, for which similar "sample maximum, plus a gap" solutions exist, most simplym +m/n − 1. A more formal application of this uniformization of spacing occurs inmaximum spacing estimation of parameters.
Thek / (n + 1) approach equals that of plotting the points according to the probability that the last of (n + 1) randomly drawn values will not exceed thek-th smallest of the firstn randomly drawn values.[7][8]
In using anormal probability plot, the quantiles one uses are therankits, the quantile of the expected value of the order statistic of a standard normal distribution.
More generally,Shapiro–Wilk test uses the expected values of the order statistics of the given distribution; the resulting plot and line yields thegeneralized least squares estimate for location and scale (from theintercept andslope of the fitted line).[9]Although this is not too important for the normal distribution (the location and scale are estimated by the mean and standard deviation, respectively), it can be useful for many other distributions.
However, this requires calculating the expected values of the order statistic, which may be difficult if the distribution is not normal.
Alternatively, one may use estimates of themedian of the order statistics, which one can compute based on estimates of the median of the order statistics of a uniform distribution and the quantile function of the distribution; this was suggested byFilliben (1975).[9]
This can be easily generated for any distribution for which the quantile function can be computed, but conversely the resulting estimates of location and scale are no longer precisely the least squares estimates, though these only differ significantly forn small.
Several different formulas have been used or proposed asaffinesymmetrical plotting positions. Such formulas have the form(k −a) / (n + 1 − 2a) for some value ofa in the range from 0 to 1, which gives a range betweenk / (n + 1) and(k − 1) / (n − 1).
Expressions include:
For large sample size,n, there is little difference between these various expressions.
The order statistic medians are the medians of theorder statistics of the distribution. These can be expressed in terms of the quantile function and theorder statistic medians for the continuous uniform distribution by:whereU(i) are the uniform order statistic medians andG is the quantile function for the desired distribution. The quantile function is the inverse of thecumulative distribution function (probability thatX is less than or equal to some value). That is, given a probability, we want the corresponding quantile of the cumulative distribution function.
James J. Filliben uses the following estimates for the uniform order statistic medians:[15]The reason for this estimate is that the order statistic medians do not have a simple form.
TheR programming language comes with functions to make Q–Q plots, namely qqnorm and qqplot from thestats package. Thefastqq package implements faster plotting for large number of data points.