# Path: simplestatistics/statistics/quantile.py
# def quantile(data, p=[0, .25, .5, .75, 1]): # pylint: disable=dangerous-default-value
#     """
#     Quantiles_ are "are cutpoints dividing the range of a probability distribution
#     into contiguous intervals with equal probabilities, or dividing the observations
#     in a sample in the same way".
#     This function assumes the data provided is a statistical population, not sample.
# 
#     Consider the first example below:
# 
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .25)
#         7
# 
#     Given the probability 0.25, 7 is the value below which you can find 25%
#     of the values after the data is sorted.
# 
#     .. _Quantiles: https://en.wikipedia.org/wiki/Quantile
# 
#     Args:
#         data: The sample. A list of numerical objects.
#         p: Can be a numerical object (int or float) indicating one quantile, or a list of
#             numerical objects indicating several quantiles.
#             p is `[0, 0.25, 0.5, 0.75, 1]` by default.
# 
#     Returns:
#         A numerical object if provided p was a single value, or a list of quantiles
#         if provided p was a list.
#         The list will be returned in the order of quantiles provided.
# 
#     Examples:
# 
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .25)
#         7
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .5)
#         9
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .75)
#         15
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 1)
#         20
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20])
#         [3, 7, 9, 15, 20]
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], [.75, .25])
#         [15, 7]
# 
#         >>> quantile(4, .5)
#         Traceback (most recent call last):
#             ...
#         TypeError: quantile expects a list of numerical objects.
#     """
#     # this function needs a list
#     if type(data) is not list:
#         raise TypeError("quantile expects a list of numerical objects.")
# 
#     data.sort()
# 
#     if type(p) in [int, float]:
#         return(get_q_value(data, p))
#     elif type(p) is list:
#         quantiles = []
#         for prob in p:
#             quantiles.append(get_q_value(data, prob))
# 
#         return(quantiles)


from .quantile import quantile
    """
    The `interquartile range`_ is the difference between the third
    and first quartiles of a numerical list. It is a measure of
    dispersion, or the spread of a distribution.

    .. _`interquartile range`: https://en.wikipedia.org/wiki/Interquartile_range

    Args:
        x: A list or tuple of numerical objects.

    Returns:
        An int or float of the difference between third and first quartiles.

    Examples:
        >>> interquartile_range([1, 2, 3, 4])
        2
        >>> interquartile_range([1, 3, 5, 7])
        4
        >>> interquartile_range(4)
        Traceback (most recent call last):
            ...
        TypeError: interquartile_range() expects a list or tuple.
    """

    if type(x) not in [list, tuple]:
        raise TypeError('interquartile_range() expects a list or tuple.')

    x.sort()

    q1 = quantile(x, .25)

# Path: simplestatistics/statistics/quantile.py
# def quantile(data, p=[0, .25, .5, .75, 1]): # pylint: disable=dangerous-default-value
#     """
#     Quantiles_ are "are cutpoints dividing the range of a probability distribution
#     into contiguous intervals with equal probabilities, or dividing the observations
#     in a sample in the same way".
#     This function assumes the data provided is a statistical population, not sample.
# 
#     Consider the first example below:
# 
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .25)
#         7
# 
#     Given the probability 0.25, 7 is the value below which you can find 25%
#     of the values after the data is sorted.
# 
#     .. _Quantiles: https://en.wikipedia.org/wiki/Quantile
# 
#     Args:
#         data: The sample. A list of numerical objects.
#         p: Can be a numerical object (int or float) indicating one quantile, or a list of
#             numerical objects indicating several quantiles.
#             p is `[0, 0.25, 0.5, 0.75, 1]` by default.
# 
#     Returns:
#         A numerical object if provided p was a single value, or a list of quantiles
#         if provided p was a list.
#         The list will be returned in the order of quantiles provided.
# 
#     Examples:
# 
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .25)
#         7
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .5)
#         9
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], .75)
#         15
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 1)
#         20
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20])
#         [3, 7, 9, 15, 20]
#         >>> quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], [.75, .25])
#         [15, 7]
# 
#         >>> quantile(4, .5)
#         Traceback (most recent call last):
#             ...
#         TypeError: quantile expects a list of numerical objects.
#     """
#     # this function needs a list
#     if type(data) is not list:
#         raise TypeError("quantile expects a list of numerical objects.")
# 
#     data.sort()
# 
#     if type(p) in [int, float]:
#         return(get_q_value(data, p))
#     elif type(p) is list:
#         quantiles = []
#         for prob in p:
#             quantiles.append(get_q_value(data, prob))
# 
#         return(quantiles)


# Path: simplestatistics/statistics/interquartile_range.py
from .quantile import quantile

    """
    The `interquartile range`_ is the difference between the third
    and first quartiles of a numerical list. It is a measure of
    dispersion, or the spread of a distribution.

    .. _`interquartile range`: https://en.wikipedia.org/wiki/Interquartile_range

    Args:
        x: A list or tuple of numerical objects.

    Returns:
        An int or float of the difference between third and first quartiles.

    Examples:
        >>> interquartile_range([1, 2, 3, 4])
        2
        >>> interquartile_range([1, 3, 5, 7])
        4
        >>> interquartile_range(4)
        Traceback (most recent call last):
            ...
        TypeError: interquartile_range() expects a list or tuple.
    """

    if type(x) not in [list, tuple]:
        raise TypeError('interquartile_range() expects a list or tuple.')

    x.sort()

    q1 = quantile(x, .25)

    q3 = quantile(x, .75)