def ensure_symmetric(K):
    """
    Ensure a symmetric matrix. Small deviations in symmetry can present obstacles to ``numpy.svd`` used by samplers.

    .. math:
        \mathbf{K} = \dfrac{\math{K} + \math{K}^T}{2}

    :param K: (``numpy.ndarray``)  Kernel matrix of shape ``(n, n)``.

    :return: (``numpy.ndarray``)  Correction to C up to symmetry.
    """
    return (K + K.T) / 2.0