def _GeomMeanAndStdDevFromHistogram(histogram):
    "Generates the geom. mean and std. dev. for a histogram.\n\n  A histogram is a collection of numerical buckets with associated\n  counts; a bucket can either represent a number of instances of a single\n  value ('low'), or from within a range of values (in which case 'high' will\n  specify the upper bound). We compute the statistics by treating the\n  histogram analogously to a list of individual values, where the counts tell\n  us how many of each value there are.\n\n  Args:\n    histogram: A histogram dict with a list 'buckets' of buckets.\n\n  Returns:\n    The geometric mean and standard deviation of the given histogram.\n  "
    if ('buckets' not in histogram):
        return (0.0, 0.0)
    count = 0
    sum_of_logs = 0
    for bucket in histogram['buckets']:
        if ('high' in bucket):
            bucket['mean'] = ((bucket['low'] + bucket['high']) / 2.0)
        else:
            bucket['mean'] = bucket['low']
        if (bucket['mean'] > 0):
            sum_of_logs += (math.log(bucket['mean']) * bucket['count'])
            count += bucket['count']
    if (count == 0):
        return (0.0, 0.0)
    sum_of_squares = 0
    geom_mean = math.exp((sum_of_logs / count))
    for bucket in histogram['buckets']:
        if (bucket['mean'] > 0):
            sum_of_squares += (((bucket['mean'] - geom_mean) ** 2) * bucket['count'])
    return (geom_mean, math.sqrt((sum_of_squares / count)))
Generates the geom. mean and std. dev. for a histogram.

A histogram is a collection of numerical buckets with associated
counts; a bucket can either represent a number of instances of a single
value ('low'), or from within a range of values (in which case 'high' will
specify the upper bound). We compute the statistics by treating the
histogram analogously to a list of individual values, where the counts tell
us how many of each value there are.

Args:
  histogram: A histogram dict with a list 'buckets' of buckets.

Returns:
  The geometric mean and standard deviation of the given histogram.
def _GeomMeanAndStdDevFromHistogram(histogram):
    "Generates the geom. mean and std. dev. for a histogram.\n\n  A histogram is a collection of numerical buckets with associated\n  counts; a bucket can either represent a number of instances of a single\n  value ('low'), or from within a range of values (in which case 'high' will\n  specify the upper bound). We compute the statistics by treating the\n  histogram analogously to a list of individual values, where the counts tell\n  us how many of each value there are.\n\n  Args:\n    histogram: A histogram dict with a list 'buckets' of buckets.\n\n  Returns:\n    The geometric mean and standard deviation of the given histogram.\n  "
    if ('buckets' not in histogram):
        return (0.0, 0.0)
    count = 0
    sum_of_logs = 0
    for bucket in histogram['buckets']:
        if ('high' in bucket):
            bucket['mean'] = ((bucket['low'] + bucket['high']) / 2.0)
        else:
            bucket['mean'] = bucket['low']
        if (bucket['mean'] > 0):
            sum_of_logs += (math.log(bucket['mean']) * bucket['count'])
            count += bucket['count']
    if (count == 0):
        return (0.0, 0.0)
    sum_of_squares = 0
    geom_mean = math.exp((sum_of_logs / count))
    for bucket in histogram['buckets']:
        if (bucket['mean'] > 0):
            sum_of_squares += (((bucket['mean'] - geom_mean) ** 2) * bucket['count'])
    return (geom_mean, math.sqrt((sum_of_squares / count)))