Interquartile range of probability distribution object
r = iqr(pd)
pd— Probability distributionprobability distribution object
Probability distribution, specified as a probability distribution
object. Create a probability distribution object with specified parameter
for fittable distributions, create a probability distribution object
by fitting it to data using
the Distribution Fitting app.
Load the sample data. Create a vector containing the first column of students' exam grade data.
load examgrades; x = grades(:,1);
Crete a normal distribution object by fitting it to the data.
pd = fitdist(x,'Normal')
pd = NormalDistribution Normal distribution mu = 75.0083 [73.4321, 76.5846] sigma = 8.7202 [7.7391, 9.98843]
Compute the interquartile range of the fitted distribution.
r = iqr(pd)
r = 11.7634
The returned result indicates that the difference between the 75th and 25th percentile of the students' grades is 11.7634.
icdf to determine the 75th and
25th percentiles of the students' grades.
y = icdf(pd,[0.25,0.75])
y = 69.1266 80.8900
Calculate the difference between the 75th and 25th percentiles.
This yields the same result as
ans = 11.7634
boxplot to visualize the interquartile
The top line of the box shows the 75th percentile, and the bottom line shows the 25th percentile. The center line shows the median, which is the 50th percentile.