def marg_dist(X_idx, centroids, ccov, mc):
    """Finds the marginal distribution p(X) for a GMM.

    Parameters
    ----------
    X_idx : list
        Indecies of dimensions to keep
    centroids : list
        List of cluster centers - [ [x1,y1,..],..,[xN, yN,..] ]
    ccov : list
        List of cluster co-variances DxD matrices
    mc : list
        Mixing cofficients for each cluster (must sum to one) by default equal
        for each cluster.

    Returns
    -------
    res : tuple
        A tuple containing a new set of (centroids, ccov, mc) for the
        marginal distribution.
    """
    new_cen = []
    new_cov = []
    for i in range(len(centroids)):
        new_cen.append(centroids[i][X_idx])
        new_cov.append(ccov[i][X_idx,:][:,X_idx])
    new_mc = mc
    return (new_cen, new_cov, new_mc)