plot::QQplot

Statistical quantile-quantile plots

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

plot::QQplot([a1, a2, …], [b1, b2, …], <a = amin .. amax>, options)
plot::QQplot([[a1, a2, …], [b1, b2, …]], <a = amin .. amax>, options)
plot::QQplot(A, <a = amin .. amax>, options)
plot::QQplot(s, <c1, c2>, <a = amin .. amax>, options)
plot::QQplot(s, <[c1, c2]>, <a = amin .. amax>, options)

Description

plot::QQplot(data1, data2) plots the quantiles of the first data set against the quantiles of the second data set.

plot::QQplot creates a quantile-quantile plot of two discrete data samples [a1, a2, …] and [b1, b2, …]. A QQ plot displays the collection of points with coordinates [x1, y1], [x2, y2] etc., where x_i = stats::empiricialQuantile([a_1, a_2, Symbol::dots])(i/(n - 1)) and y_i = stats::empiricialQuantile([b_1, b_2, Symbol::dots])(i/(n - 1)) with i running from 0 through n - 1. The number of plot points n is set by the attribute Size = n. If no value is specified by the user, n is chosen as the minimum of the lengths of the data lists [a1, a2, …] and [b1, b2, …].

In addition, the diagonal reference line y = x is displayed in the plot. This line can be suppressed by the attribute LinesVisible = FALSE.

The samples [a1, a2, ] and [b1, b2, ] do not need to have the same length.

A QQ plot is a graphical technique for determining if two data sets come from populations with a common distribution.

If the two sets come from a population with the same distribution, the points of the QQ plot should fall approximately along the reference line y = x. The greater the departure from this reference line, the greater the evidence for the conclusion that the two data sets have come from populations with different distributions.

A specialized version of the QQ plot is the “probability plot”, where the quantiles of one of the data samples are replaced with the quantiles of a theoretical distribution. You can use plot::QQplot for this type of plot, too, by using a reference list such as

[stats::normalQuantile(0, 1)(i/n) $ i = 1 .. n-1]

as one of the data lists. In this particular case, data obeying a standard normal distribution should produce plot points close to the diagonal reference line y = x.

Cf. Example 3.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
AntiAliasedantialiased lines and points?TRUE
Datathe (statistical) data to plot 
Framesthe number of frames in an animation50
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
LineColorcolor of linesRGB::Red
LineWidthwidth of lines0.35
LineStylesolid, dashed or dotted lines?Solid
LinesVisiblevisibility of linesTRUE
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
PointSizethe size of points1.5
PointColorthe color of pointsRGB::Black
PointStylethe presentation style of pointsFilledCircles
PointsVisiblevisibility of mesh pointsTRUE
Sizesize of a point list 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE

Examples

Example 1

We create a QQ plot of some data samples:

a := [6, 9, 17,  0, 13, 9, 9, 12, 12, 12]:
b := [7, 8, 20,  2, 11, 8, 9, 12, 13, 15, 2, 14]:
q := plot::QQplot(a, b):
plot(q)

We can modify the appearance of the QQ plot in various ways:

q::PointColor := RGB::Red:
q::PointSize := 3*unit::mm:
q::LineColor := RGB::Black:
q::LineWidth := 1*unit::mm:
plot(q)

delete a, b, q:

Example 2

We create some samples:

a := [stats::uniformRandom(-1, 1)() $ k = 1..100]:
b := [stats::normalRandom(0, 1)() $ k = 1..300]:
c := [stats::normalRandom(0, 1)() $ k = 1..500]:

The left QQ-plot shows a clear deviation from the reference line y = x. The samples a and b do not seem to be chosen from the same population. The QQ plot of the samples b and c (both normally distributed with mean 0 and variance 1), however, shows data points close to the reference line:

plot(plot::Scene2d(plot::QQplot(a, b)),
     plot::Scene2d(plot::QQplot(b, c)),
     Width = 20*unit::cm, Rows = 1)

delete a, b, c:

Example 3

We create a normally distributed sample:

data1 := [stats::normalRandom(0, 1)() $ k = 1..100]:

We wish to investigate whether these data can indeed be regarded as normally distributed. We create a reference sample of data that are definitely normally distributed:

n:= nops(data1):
data2 := [stats::normalQuantile(0, 1)(i/n) $ i = 1 .. n-1]:

The QQ plot of the data shows plot points close to the reference line y = x:

plot(plot::QQplot(data1, data2))

delete data1, n, data2:

Parameters

a1, a2, …, b1, b2, …

The statistical data: numerical real values or arithmetical expressions of the animation parameter a.

a1, a2, …, b1, b2, … are equivalent to the attribute Data.

A

An array of domain type DOM_ARRAY or a matrix of category Cat::Matrix (e.g., of type matrix or densematrix) providing numerical real values or arithmetical expressions of the animation parameter a. The array/matrix must have 2 columns. The first column is regarded as the data set [a1, a2, …] the second column is regarded as the data set [b1, b2, …]. If more columns are provided, the superfluous columns are ignored.

A is equivalent to the attribute Data.

s

A data collection of domain type stats::sample. Two columns in s are regarded as the data lists [a1, a2, …] and [b1, b2, …] respectively.

s is equivalent to the attribute Data.

c1, c2

Column indices into s: positive integers. These indices, if given, indicate that only the specified columns in s should be used. If no column indices are specified, the first two columns in s are used as the data sets [a1, a2, …] and [b1, b2, …], respectively.

a

Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives