

def _increment_multivariate_gaussian_cov(X, m, S, n, bias=0):
    new_n = X.shape[0]
    new_m = _increment_multivariate_gaussian_mean(X, m, n)
    if (bias == 1):
        k = n
    elif (bias == 0):
        k = (n - 1)
    else:
        raise ValueError('bias must be either 0 or 1')
    m1 = (n * m[None, :].T.dot(m[None, :]))
    m2 = ((n + new_n) * new_m[None, :].T.dot(new_m[None, :]))
    new_S = (((((k * S) + m1) + X.T.dot(X)) - m2) / (k + new_n))
    return (new_m, new_S)

dataset/ETHPy150Open menpo/menpo/menpo/model/gmrf.py _increment_multivariate_gaussian_cov/original