def finalize(cur_aggregate):
    """Retrieve the mean and variance from an aggregate."""
    (count, mean, m_2) = cur_aggregate
    mean, variance = mean, m_2 / (count - 1)
    if count < 2:
        return float('nan')
    else:
        return mean, variance