Normal probability plot
h = normplot(x)
normplot( displays a normal probability plot of
the data contained in
x. Use a normal probability plot to
assess visually whether the sample data in
x comes from a
population with a normal distribution. If the sample data has a normal distribution,
then the data appears along the reference line. Distributions other than normal can
introduce curvature in the 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.
The plot indicates that the data follows a normal distribution.
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)
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;
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')
x— Sample data
Sample data, specified as a numeric vector or numeric matrix.
each value in
x using the symbol
x is a matrix, then
a separate line for each column of
h— Graphic handles for line objects
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
The line representing the data points.
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
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 (MATLAB).
For information on the
Line properties that you
can set, see Line Properties.
normplot matches the quantiles of sample data to the quantiles of
a normal distribution. The sample data is sorted and plotted on the x-axis. The y-axis
represents the quantiles of the normal distribution, converted into probability values.
Therefore, the y-axis scaling is not linear.
Where the x-axis value is the ith sorted value from a sample of
size N, the y-axis value is the midpoint between evaluation points of
the empirical cumulative distribution function of the data. In the case of uncensored
data, the midpoint is equal to . When the data includes censored observations, use
normplot superimposes a reference line to assess the linearity of
the plot. The line goes through the first and third quartiles of the data.