"""
Implements geometric_mean() function.
"""

# Python 3: reduce is now in functools
# ref: http://stackoverflow.com/questions/8689184/python-name-reduce-is-not-defined
from functools import reduce

# geometric mean
#
# a mean function that is more useful for numbers in different
# ranges.
#
# this is the nth root of the input numbers multipled by each other
#
# This runs on `O(n)`, linear time in respect to the array
def geometric_mean(data):
    """
    The `geometric mean`_ uses the product of a set of numbers to determine their central tendency,
    as opposed to the regular arithmetic mean which uses their sum.

    .. _`geometric mean`: https://en.wikipedia.org/wiki/Geometric_mean

    Equation:
        .. math::
            \\sqrt[n]{x_1 x_2 \\dotso x_n}

    Args:
        data: A list of numeric objects.

    Returns:
        A float object.

    Examples:
        >>> geometric_mean([1])
        1.0
        >>> geometric_mean([1, 10])
        3.1622776601683795
    """
    return pow(reduce(lambda v, mem: v * mem, data, 1.0), 1 / float(len(data)))

9517ece3ddb6bfc38310bba5e3c05b5eb4c655a4
<mask token>

<mask token>


def geometric_mean(data):
    """
    The `geometric mean`_ uses the product of a set of numbers to determine their central tendency,
    as opposed to the regular arithmetic mean which uses their sum.

    .. _`geometric mean`: https://en.wikipedia.org/wiki/Geometric_mean

    Equation:
        .. math::
            \\sqrt[n]{x_1 x_2 \\dotso x_n}

    Args:
        data: A list of numeric objects.

    Returns:
        A float object.

    Examples:
        >>> geometric_mean([1])
        1.0
        >>> geometric_mean([1, 10])
        3.1622776601683795
    """
    return pow(reduce(lambda v, mem: v * mem, data, 1.0), 1 / float(len(data)))

<mask token>
from functools import reduce


def geometric_mean(data):
    """
    The `geometric mean`_ uses the product of a set of numbers to determine their central tendency,
    as opposed to the regular arithmetic mean which uses their sum.

    .. _`geometric mean`: https://en.wikipedia.org/wiki/Geometric_mean

    Equation:
        .. math::
            \\sqrt[n]{x_1 x_2 \\dotso x_n}

    Args:
        data: A list of numeric objects.

    Returns:
        A float object.

    Examples:
        >>> geometric_mean([1])
        1.0
        >>> geometric_mean([1, 10])
        3.1622776601683795
    """
    return pow(reduce(lambda v, mem: v * mem, data, 1.0), 1 / float(len(data)))

"""
Implements geometric_mean() function.
"""

# Python 3: reduce is now in functools
# ref: http://stackoverflow.com/questions/8689184/python-name-reduce-is-not-defined
from functools import reduce

# geometric mean
#
# a mean function that is more useful for numbers in different
# ranges.
#
# this is the nth root of the input numbers multipled by each other
#
# This runs on `O(n)`, linear time in respect to the array
def geometric_mean(data):
    """
    The `geometric mean`_ uses the product of a set of numbers to determine their central tendency,
    as opposed to the regular arithmetic mean which uses their sum.

    .. _`geometric mean`: https://en.wikipedia.org/wiki/Geometric_mean

    Equation:
        .. math::
            \\sqrt[n]{x_1 x_2 \\dotso x_n}

    Args:
        data: A list of numeric objects.

    Returns:
        A float object.

    Examples:
        >>> geometric_mean([1])
        1.0
        >>> geometric_mean([1, 10])
        3.1622776601683795
    """
    return pow(reduce(lambda v, mem: v * mem, data, 1.0), 1 / float(len(data)))
