def geometric_mean(values): """Compute the geometric mean of a sequence of numbers. >>> round(geometric_mean([2, 8]), 2) 4.0 """ assert None not in values exp = 1.0 / len(values) return tools.product([val**exp for val in values])
def geometric_mean_old(values): return tools.product(values)**(1.0 / len(values))