# normplot

Normal probability plot

## Syntax

• ``normplot(x)``
example
• ``h = normplot(x)``
example

## Description

example

````normplot(x)` displays a normal probability plot of the data contained in `x`. Use a normal probability plot to assess visually whether the data in `x` comes from a population with a normal distribution.```

example

````h = normplot(x)` also returns a column vector of handles to the `Line` objects created by `normplot`.```

## Examples

collapse all

### Generate a Normal Probability Plot

Generate random sample data from a normal distribution with `mu = 10` and `sigma = 1`.

```rng default; % For reproducibility x = normrnd(10,1,25,1); ```

Create a normal probability plot of the sample data.

```figure; normplot(x) ```

The plot indicates that the data follows a normal distribution.

### Adjust Normal Probability Plot Line Properties

Create a 50-by-2 matrix containing 50 random numbers from each of two different distributions: A standard normal distribution in column 1, and a set of Pearson random numbers with `mu` equal to 0, `sigma` equal to 1, skewness equal to 0.5, and kurtosis equal to 3 (a "right-skewed" distribution) in column 2.

```rng default % For reproducibility x = [normrnd(0,1,[50,1]) pearsrnd(0,1,0.5,3,[50,1])]; ```

Create a normal probability plot for both samples on the same figure. Return the plot line graphic handles.

```figure h = normplot(x) legend({'Normal','Right-Skewed'},'Location','southeast') ```
```h = 6x1 Line array: Line Line Line Line Line Line ```

The handles h(1) and h(2) correspond to the data points for the normal and skewed distributions, respectively. The handles h(3) and h(4) correspond to the second and third quartile line fit to the sample data. The handles h(5) and h(6) correspond to the extrapolated line that extends to the minimum and maximum of each set of sample data.

To illustrate, increase the line width of the second and third quartile line for the normally distributed data sample (represented by h(3)) to 2.

```h(3).LineWidth = 2; h(4).LineWidth = 2; ```

### Assess Normalilty Using a Normal Probability Plot

Generate 50 random numbers from each of four different distributions: A standard normal distribution; a Student's-t distribution with five degrees of freedom (a "fat-tailed" distribution); a set of Pearson random numbers with `mu` equal to 0, `sigma` equal to 1, skewness equal to 0.5, and kurtosis equal to 3 (a "right-skewed" distribution); and a set of Pearson random numbers with `mu` equal to 0, `sigma` equal to 1, skewness equal to -0.5, and kurtosis equal to 3 (a "left-skewed" distribution).

```rng(11) % For reproducibility x1 = normrnd(0,1,[50,1]); x2 = trnd(5,[50,1]); x3 = pearsrnd(0,1,0.5,3,[50,1]); x4 = pearsrnd(0,1,-0.5,3,[50,1]); ```

Plot four histograms on the same figure for a visual comparison of the pdf of each distribution.

```figure subplot(2,2,1) histogram(x1,10) title('Normal') axis([-4,4,0,15]) subplot(2,2,2) histogram(x2,10) title('Fat Tails') axis([-4,4,0,15]) subplot(2,2,3) histogram(x3,10) title('Right-Skewed') axis([-4,4,0,15]) subplot(2,2,4) histogram(x4,10) title('Left-Skewed') axis([-4,4,0,15]) ```

The histograms show how each sample differs from the normal distribution.

Create a normal probability plot for each sample.

```figure subplot(2,2,1) normplot(x1) title('Normal') subplot(2,2,2) normplot(x2) title('Fat Tails') subplot(2,2,3) normplot(x3) title('Right-Skewed') subplot(2,2,4) normplot(x4) title('Left-Skewed') ```

## Input Arguments

collapse all

### `x` — Sample datanumeric vector | numeric matrix

Sample data, specified as a numeric vector or numeric matrix. `normplot` displays each value in `x` using the symbol `'+'`. If `x` is a matrix, then `normplot` displays a separate line for each column of `x`.

Data Types: `single` | `double`

## Output Arguments

collapse all

### `h` — Graphic handles for line objectsvector of `Line` graphic handles

Graphic handles for line objects, returned as a vector of Line graphic handles. Graphic handles are unique identifiers that you can use to query and modify the properties of a specific line on the plot. For each column of `x`, `normplot` returns three handles:

• The line representing the data points. `normplot` represents each data point in `x` using the plot symbol `'+'`.

• The line joining the first and third quartiles of each column of `x`, represented as a solid line.

• The extrapolation of the quartile line, extended to the minimum and maximum values of `x`, represented as a dashed line.

To view and set properties of line objects, use dot notation. For information on using dot notation, see Access Property Values. For information on the `Line` properties that you can set, see Primitive Line Properties.

collapse all

### Normal Probability Plot

Use a normal probability plot to assess graphically whether sample data has a normal distribution and the type of departure from normality, if any.

A normal probability plot plots the empirical cumulative distribution of the sample data versus the theoretical cumulative distribution function of a normal distribution. The horizontal axis plots the sorted sample data. The vertical axis plots the normal order statistic medians, calculated using the uniform order statistic medians and the inverse cumulative distribution function (icdf) of the normal distribution. If the sample data has a normal distribution, then the plot appears linear. Distributions other than normal introduce curvature in the plot.

`normplot` superimposes a fit line onto the plot using a robust linear fit of the sample order statistics for the data in second and third quartile of the sample data. `normplot` then extrapolates linearly to the minimum and maximum values in the sample to help visually assess the data in the tails.

`normplot` uses midpoint probability plotting positions to plot along the y-axis. The ith sorted value from a sample of size N is plotted against the midpoint between tick marks of the empirical cdf on the y-axis. If the sample data is uncensored, the midpoint is equal to $\frac{\left(i-0.5\right)}{N}$. If your sample data includes censored observations, use `probplot` instead of `normplot` to create a normal probability plot.