# 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/sum.py
# def sum(data): # pylint: disable=redefined-builtin
#     """
#     This function returns the sum of numerical values in a data set.
# 
#     To reduce floating-point errors, I am using an implementation of the
#     `Kahan summation algorithm`_.
# 
#     .. _`Kahan summation algorithm`: https://en.wikipedia.org/wiki/Kahan_summation_algorithm
# 
#     The implementation is modeled after that of `simple-statistics \
#     <https://github.com/simple-statistics/simple-statistics/blob/master/src/sum.js>`_.
# 
#     Args:
#         data: A numeric built-in object or list of numeric objects.
# 
#     Returns:
#         A numeric object.
# 
#     Examples:
#         >>> sum([1, 2, 3])
#         6
#         >>> sum([-1, 0, 1])
#         0
#         >>> sum([2.3, 0, -1.1])
#         1.2
#         >>> sum(4)
#         4
#         >>> sum((3, 2.5))
#         5.5
#         >>> sum([1.00001, 1.00002])
#         2.0
#         >>> sum([1.0001, 1.0002])
#         2.0
#         >>> sum([1.001, 1.002])
#         2.003
#         >>> sum('abc')
#         Traceback (most recent call last):
#             ...
#         TypeError: sum() expects an int, list, or tuple.
#     """
#     current_sum = 0
# 
#     error_compensation = 0
#     corrected_current_value = 0
#     next_sum = 0
# 
#     if type(data) in [int, float]:
#         return(data)
#     elif type(data) in [list, tuple]:
#         for ii, _ in enumerate(data):
#             corrected_current_value = data[ii] - error_compensation
# 
#             next_sum = current_sum + corrected_current_value
# 
#             error_compensation = next_sum - current_sum - corrected_current_value
# 
#             current_sum = next_sum
# 
#         # floating-point errors are unavoidable
#         # with all measures taken above, we will still need
#         # to round to 3 decimal points sometimes
#         return(round(current_sum, 3))
#     else:
#         raise TypeError("sum() expects an int, list, or tuple.")


from .mean import mean
from .sum import sum # pylint: disable=redefined-builtin
        which can be rewritten as

        .. math::
            \\gamma_1 = \\frac{\\frac{1}{n} \\sum(X - \\mu)^3}{\\frac{1}{n}
            (\\sum(X - \\mu)^2)^{3/2}}

    Args:
        x: A list of numerical objects.

    Returns:
        A numerical object.

    Examples:

        >>> skew([1, 2, 3])
        0.0
        >>> skew([1, 2, 5])
        0.5279896038431618
        >>> skew([20, 30]) # skew of a variable that contains two observations is always 0
        0.0
        >>> skew(9) # no skew for a single number/value
    """

    if type(x) in [int, float]:
        return(None)

    mean_x = mean(x)
    n = len(x)

    m2 = sum([pow((value - mean_x), 2) for value in x]) * (1/n)

# 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/sum.py
# def sum(data): # pylint: disable=redefined-builtin
#     """
#     This function returns the sum of numerical values in a data set.
# 
#     To reduce floating-point errors, I am using an implementation of the
#     `Kahan summation algorithm`_.
# 
#     .. _`Kahan summation algorithm`: https://en.wikipedia.org/wiki/Kahan_summation_algorithm
# 
#     The implementation is modeled after that of `simple-statistics \
#     <https://github.com/simple-statistics/simple-statistics/blob/master/src/sum.js>`_.
# 
#     Args:
#         data: A numeric built-in object or list of numeric objects.
# 
#     Returns:
#         A numeric object.
# 
#     Examples:
#         >>> sum([1, 2, 3])
#         6
#         >>> sum([-1, 0, 1])
#         0
#         >>> sum([2.3, 0, -1.1])
#         1.2
#         >>> sum(4)
#         4
#         >>> sum((3, 2.5))
#         5.5
#         >>> sum([1.00001, 1.00002])
#         2.0
#         >>> sum([1.0001, 1.0002])
#         2.0
#         >>> sum([1.001, 1.002])
#         2.003
#         >>> sum('abc')
#         Traceback (most recent call last):
#             ...
#         TypeError: sum() expects an int, list, or tuple.
#     """
#     current_sum = 0
# 
#     error_compensation = 0
#     corrected_current_value = 0
#     next_sum = 0
# 
#     if type(data) in [int, float]:
#         return(data)
#     elif type(data) in [list, tuple]:
#         for ii, _ in enumerate(data):
#             corrected_current_value = data[ii] - error_compensation
# 
#             next_sum = current_sum + corrected_current_value
# 
#             error_compensation = next_sum - current_sum - corrected_current_value
# 
#             current_sum = next_sum
# 
#         # floating-point errors are unavoidable
#         # with all measures taken above, we will still need
#         # to round to 3 decimal points sometimes
#         return(round(current_sum, 3))
#     else:
#         raise TypeError("sum() expects an int, list, or tuple.")


# Path: simplestatistics/statistics/skew.py
from .mean import mean
from .sum import sum # pylint: disable=redefined-builtin

        which can be rewritten as

        .. math::
            \\gamma_1 = \\frac{\\frac{1}{n} \\sum(X - \\mu)^3}{\\frac{1}{n}
            (\\sum(X - \\mu)^2)^{3/2}}

    Args:
        x: A list of numerical objects.

    Returns:
        A numerical object.

    Examples:

        >>> skew([1, 2, 3])
        0.0
        >>> skew([1, 2, 5])
        0.5279896038431618
        >>> skew([20, 30]) # skew of a variable that contains two observations is always 0
        0.0
        >>> skew(9) # no skew for a single number/value
    """

    if type(x) in [int, float]:
        return(None)

    mean_x = mean(x)
    n = len(x)

    m2 = sum([pow((value - mean_x), 2) for value in x]) * (1/n)

    m3 = sum([pow((value - mean_x), 3) for value in x]) * (1/n)