def geometric_mean(values):
    """Calculate geometric mean in numpy array.

    Avoids numerical over- and underflow at the cost of compute time.

    Args:
        values (ndarray)
    Returns:
        float

    """
    inv_len = 1.0 / values.size
    x = values**inv_len
    return x.prod()