Use ``data`` from multiple "Iterative Simulations" (e.g. Markov
    Chains) to form a Student t 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`` Student t 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 Student t
    component with its empirical mean, covariance and degree of freedom
    is created.

    Return a :py:class:`pypmc.density.mixture.MixtureDensity` with
    :py:class:`pypmc.density.student_t.StudentT` components.

    .. seealso::

        :py:func:`.make_r_gaussmix`

    :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 dof:

        Float; the degree of freedom the components will have.

    :param indices:

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

def make_r_tmix(data, K_g=15, critical_r=2., dof=5., indices=None, approx=False):
    '''Use ``data`` from multiple "Iterative Simulations" (e.g. Markov
    Chains) to form a Student t 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`` Student t 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 Student t
    component with its empirical mean, covariance and degree of freedom
    is created.

    Return a :py:class:`pypmc.density.mixture.MixtureDensity` with
    :py:class:`pypmc.density.student_t.StudentT` components.

    .. seealso::

        :py:func:`.make_r_gaussmix`

    :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 dof:

        Float; the degree of freedom the components will have.

    :param indices:

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

    '''
    assert dof > 2., "``dof`` must be larger than 2. (got %g)" %dof

    means, covs = _make_r_patches(data, K_g, critical_r, indices, approx)

    sigmas  = _np.asarray(covs)
    # cov = nu / (nu-2) * sigma
    sigmas *= (dof - 2.) / dof

    return _mkt(means, sigmas, [dof] * len(means))