Documentation

# `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
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`AntiAliased`antialiased lines and points?`TRUE`
`Data`the (statistical) data to plot
`Frames`the number of frames in an animation`50`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Red`
`LineWidth`width of lines`0.35`
`LineStyle`solid, dashed or dotted lines?`Solid`
`LinesVisible`visibility of lines`TRUE`
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`PointSize`the size of points`1.5`
`PointColor`the color of points`RGB::Black`
`PointStyle`the presentation style of points`FilledCircles`
`PointsVisible`visibility of mesh points`TRUE`
`Size`size of a point list
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object 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.

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos