Use ``data`` from multiple "Iterative Simulations" (e.g. Markov
    Chains) to form a Gaussian Mixture. This approach refers to the
    "long patches" in [BC13]_.

    The idea is to group chains according to their R-value as in
    :py:func:`.r_group` and form ``K_g`` Gaussian Components per chain
    group. Once the groups are found by :py:func:`.r_group`, the ``data``
    from each chain group is partitioned into ``K_g`` parts (using
    :py:func:`pypmc.tools.partition`). For each of these parts a Gaussian
    with its empirical mean and covariance is created.

    Return a :py:class:`pypmc.density.mixture.MixtureDensity` with
    :py:class:`pypmc.density.gauss.Gauss` components.

    .. seealso::

        :py:func:`.make_r_tmix`

    :param data:

        Iterable of matrix-like arrays; the individual items are interpreted
        as points from an individual chain.

        .. important::
            Every chain must bring the same number of points.

    :param K_g:

        Integer; the number of components per chain group.

    :param critical_r:

        Float; the maximum R value a chain group may have.

    :param indices:

        Integer; Iterable of Integers; use R value in these dimensions
        only. Default is all.

    .. note::

        If ``K_g`` is too large, some covariance matrices may not be positive definite.
        Reduce ``K_g`` or increase ``len(data)``!

def make_r_gaussmix(data, K_g=15, critical_r=2., indices=None, approx=False):
    '''Use ``data`` from multiple "Iterative Simulations" (e.g. Markov
    Chains) to form a Gaussian Mixture. This approach refers to the
    "long patches" in [BC13]_.

    The idea is to group chains according to their R-value as in
    :py:func:`.r_group` and form ``K_g`` Gaussian Components per chain
    group. Once the groups are found by :py:func:`.r_group`, the ``data``
    from each chain group is partitioned into ``K_g`` parts (using
    :py:func:`pypmc.tools.partition`). For each of these parts a Gaussian
    with its empirical mean and covariance is created.

    Return a :py:class:`pypmc.density.mixture.MixtureDensity` with
    :py:class:`pypmc.density.gauss.Gauss` components.

    .. seealso::

        :py:func:`.make_r_tmix`

    :param data:

        Iterable of matrix-like arrays; the individual items are interpreted
        as points from an individual chain.

        .. important::
            Every chain must bring the same number of points.

    :param K_g:

        Integer; the number of components per chain group.

    :param critical_r:

        Float; the maximum R value a chain group may have.

    :param indices:

        Integer; Iterable of Integers; use R value in these dimensions
        only. Default is all.

    .. note::

        If ``K_g`` is too large, some covariance matrices may not be positive definite.
        Reduce ``K_g`` or increase ``len(data)``!

    '''
    return _mkgauss(*_make_r_patches(data, K_g, critical_r, indices, approx))