def calc_mean(histogram):
    """Calculates mean of given histogram

    :param histogram: histogram to calculate the mean for
    :type histogram: numpy.ndarray
    :returns: float -- mean of given histogram
    """
    if histogram.shape[0] == 0:
        return 0

    values = 0
    for i, value in enumerate(histogram):
        values += (value * (i + 1))

    if sum(histogram) == 0:
        return 0

    return float(values / sum(histogram))