# Path: simplestatistics/statistics/mean.py
# def mean(data):
#     """
#     The mean_, or *average*, is "the sum of values divided by the number of values".
# 
#     .. _mean: https://en.wikipedia.org/wiki/Mean
# 
#     Equation:
#         .. math::
#             \\bar{X} = \\frac{\\sum X}{n}
# 
#     Args:
#         data: A numeric built-in object, a tuple,
#             or list of numeric objects.
# 
#     Returns:
#         A float object.
# 
#     Examples:
# 
#         >>> mean([1])
#         1.0
#         >>> mean([1, 2])
#         1.5
#         >>> mean([1, 2, 3])
#         2.0
#         >>> mean([-1, 0, 1, 2, 3])
#         1.0
#     """
#     data = decimalize(copy.deepcopy(data)) # don't modify the original data
#     return float(sum(data) / len(data))


from .mean import mean

    .. _Variance: http://en.wikipedia.org/wiki/Variance

    Args:
        data: A list of numeric objects.
        sample: A boolean value. If True, calculates sample variance. If False, calculates
            population variance.

    Returns:
        A float object.

    Examples:
        >>> variance([1, 2, 3, 4])
        1.6666666666666667
        >>> variance([1, 2, 3, 4], sample = False)
        1.25
        >>> variance([1, 2, 3, 4, 5, 6])
        3.5
        >>> variance([-2, -1, 0, 1, 2])
        2.5
        >>> variance([1]) # variance of one value is not defined
        >>> variance([4]) # variance of one value is not defined
    """
    if len(data) < 2:
        return(None)

    m = mean(data)
    if sample: # pylint: disable=no-else-return
        return(float(sum([pow(x - m, 2) for x in data]) / (len(data) - 1)))
    else:

# Path: simplestatistics/statistics/mean.py
# def mean(data):
#     """
#     The mean_, or *average*, is "the sum of values divided by the number of values".
# 
#     .. _mean: https://en.wikipedia.org/wiki/Mean
# 
#     Equation:
#         .. math::
#             \\bar{X} = \\frac{\\sum X}{n}
# 
#     Args:
#         data: A numeric built-in object, a tuple,
#             or list of numeric objects.
# 
#     Returns:
#         A float object.
# 
#     Examples:
# 
#         >>> mean([1])
#         1.0
#         >>> mean([1, 2])
#         1.5
#         >>> mean([1, 2, 3])
#         2.0
#         >>> mean([-1, 0, 1, 2, 3])
#         1.0
#     """
#     data = decimalize(copy.deepcopy(data)) # don't modify the original data
#     return float(sum(data) / len(data))


# Path: simplestatistics/statistics/variance.py
from .mean import mean


    .. _Variance: http://en.wikipedia.org/wiki/Variance

    Args:
        data: A list of numeric objects.
        sample: A boolean value. If True, calculates sample variance. If False, calculates
            population variance.

    Returns:
        A float object.

    Examples:
        >>> variance([1, 2, 3, 4])
        1.6666666666666667
        >>> variance([1, 2, 3, 4], sample = False)
        1.25
        >>> variance([1, 2, 3, 4, 5, 6])
        3.5
        >>> variance([-2, -1, 0, 1, 2])
        2.5
        >>> variance([1]) # variance of one value is not defined
        >>> variance([4]) # variance of one value is not defined
    """
    if len(data) < 2:
        return(None)

    m = mean(data)
    if sample: # pylint: disable=no-else-return
        return(float(sum([pow(x - m, 2) for x in data]) / (len(data) - 1)))
    else:

        return(float(mean([pow(x - m, 2) for x in data])))