Compute mean and covariance of array of cubature points.

    Parameters
    ----------

    Xs : ndarray
        Cubature points

    Q : ndarray
        Noise covariance

    Returns
    -------

    mean : ndarray
         mean of the cubature points

    variance: ndarray
         covariance matrix of the cubature points

def ckf_transform(Xs, Q):
    """
    Compute mean and covariance of array of cubature points.

    Parameters
    ----------

    Xs : ndarray
        Cubature points

    Q : ndarray
        Noise covariance

    Returns
    -------

    mean : ndarray
         mean of the cubature points

    variance: ndarray
         covariance matrix of the cubature points
    """

    m, n = Xs.shape

    x = sum(Xs, 0)[:, None] / m
    P = np.zeros((n, n))
    xf = x.flatten()
    for k in range(m):
        P += np.outer(Xs[k], Xs[k]) - np.outer(xf, xf)

    P *= 1 / m
    P += Q

    return x, P