def _parallel_variance(avg_a, count_a, var_a, avg_b, count_b, var_b):
    """
    Calculate the new variance based on previous calcuated variance
    :param float avg_a: overall average
    :param float count_a: overall count
    :param float var_a: current variance
    :param float avg_b: ne average
    :param float count_b: current count
    :param float var_b: current variance
    :returns: new variance
    :rtype: float
    """
    delta = avg_b - avg_a
    m_a = var_a * (count_a - 1)
    m_b = var_b * (count_b - 1)
    M2 = m_a + m_b + delta ** 2 * count_a * count_b / (count_a + count_b)
    return M2 / (count_a + count_b - 1)