# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# iqr

Class: prob.TruncatableDistribution
Package: prob

Interquartile range of probability distribution object

## Syntax

```r = iqr(pd) ```

## Description

`r = iqr(pd)` returns the interquartile range `r` of the probability distribution `pd`.

## Input Arguments

expand all

Probability distribution, specified as a probability distribution object. Create a probability distribution object with specified parameter values using `makedist`. Alternatively, for fittable distributions, create a probability distribution object by fitting it to data using `fitdist` or the Distribution Fitting app.

## Output Arguments

expand all

Interquartile range of the probability distribution, returned as a scalar value. The value of `r` is the difference between the values of the 75th and 25th percentile of the probability distribution.

## Examples

expand all

Load the sample data. Create a vector containing the first column of students’ exam grade data.

```load examgrades; x = grades(:,1); ```

Create 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.

Use `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 `iqr`.

```y(2)-y(1) ```
```ans = 11.7634 ```

Use `boxplot` to visualize the interquartile range.

```boxplot(x) ```

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.