import math


def _mean_standard(dist):
    """Find the mean and standard deviation."""

    # In the dist dictionary, the key is the value of the metric and
    # the value is the number of times it appears. So, the sample
    # value is the key and the number of samples for the value is the
    # value in dist for that key.

    total_samples = sum(dist.values())

    total_values = sum(key*value
                       for key, value in dist.items())

    mean = total_values/total_samples

    std_squared = sum((value/total_samples) * (key - mean)**2
                   for key, value in dist.items())

    std = math.sqrt(std_squared)

    return mean, std