import math


def meanStd(d):
    """
    Calculate the mean and standard deviation of histogram d.

    @arg d: Histogram of real values.
    @type d: dict[int](float)

    @returns: The mean and standard deviation of d.
    @rtype: tuple(float, float)
    """
    sum_l = 0
    sumSquared_l = 0
    n = 0

    for i in d:
        sum_l += i * d[i]
        sumSquared_l += (d[i] * (i * i))
        n += d[i]
    #for
    
    mean = sum_l / float(n)
    return {'Mean.insertsize' : mean, 'stDev' :+math.sqrt((sumSquared_l / float(n)) - (mean * mean))}