def unmean(cur_mean, cur_N, value_to_remove):
    """
    Removes the influence of <value_to_remove> from a mean value that currently is calculated
    from <cur_N> samples.

    That is, if <value_to_remove> is the <cur_N>th sample, return what the mean of the 1-(<cur_N>-1)th samples
    must be.
    """
    return cur_mean * (float(cur_N) / float(cur_N - 1)
        ) - value_to_remove / float(cur_N - 1)
