def _merge_cov_data(d1, d2):
    """ Merge covariance data from two segments into a new one.
    See also:
        https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
        https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online
    """
    d3 = d1 + d2
    n1 = d1[0]
    n2 = d2[0]
    n12 = n1 * n2
    n3 = d3[0]
    deltat = (d1[1] * n2 - d2[1] * n1) / n12
    deltav = (d1[2] * n2 - d2[2] * n1) / n12
    d3[3] += deltat ** 2 * n12 / n3
    d3[4] += deltav ** 2 * n12 / n3
    d3[5] += deltat * deltav * n12 / n3
    return d3