Generate a 4-by-4 matrix of random data from a normal distribution with parameter values equal to 10 and equal to 1.
rng default % For reproducibility x = normrnd(10,1,4)
x = 10.5377 10.3188 13.5784 10.7254 11.8339 8.6923 12.7694 9.9369 7.7412 9.5664 8.6501 10.7147 10.8622 10.3426 13.0349 9.7950
Compute the interquartile range for each column of data.
r = iqr(x)
r = 2.2086 1.2013 2.5969 0.8541
Compute the interquartile range for each row of data.
r2 = iqr(x,2)
r2 = 1.7237 2.9870 1.9449 1.8797
Create a standard normal distribution object with the mean, , equal to 0 and the standard deviation, , equal to 1.
pd = makedist('Normal',0,1);
Compute the interquartile range of the standard normal distribution.
r = iqr(pd)
r = 1.3490
The returned value is the difference between the 75th and the 25th percentile values for the distribution. This is equivalent to computing the difference between the inverse cumulative distribution function (icdf) values at the probabilities y equal to 0.75 and 0.25.
r2 = icdf(pd,0.75) - icdf(pd,0.25)
r2 = 1.3490
x— Input array
Input array, specified as a vector, matrix, or multidimensional array.
Dimension along which the interquartile range is calculated,
specified as a positive integer. For example, for a matrix
dim is equal to 1,
the interquartile range for the columns of
dim is equal to 2,
the interquartile range for the rows of x. For n-dimensional
iqr operates along the first nonsingleton
pd— Probability distribution
Probability distribution, specified as a probability distribution object created using one of the following.
r— Interquartile range
Interquartile range, returned as a scalar value.
If you input a vector for
r is the difference between the 75th and
the 25th percentiles of the sample data contained in
If you input a matrix for
r is a row vector containing the difference
between the 75th and the 25th percentiles of the sample data contained
each column of
If you input a probability distribution,
then the value of
r is the difference between
the values of the 75th and 25th percentile of the probability distribution.