def mahalanobis_distance(self, samples, subtract_mean=True,
                             square_root=False):
        r"""
        Compute the mahalanobis distance given a sample :math:`\mathbf{x}` or an
        array of samples :math:`\mathbf{X}`, i.e.

        .. math::
           \sqrt{(\mathbf{x}-\boldsymbol{\mu})^T \mathbf{Q} (\mathbf{x}-\boldsymbol{\mu})}
           \text{ or }
           \sqrt{(\mathbf{X}-\boldsymbol{\mu})^T \mathbf{Q} (\mathbf{X}-\boldsymbol{\mu})}

        Parameters
        ----------
        samples : `ndarray`
            A single data vector or an array of multiple data vectors.
        subtract_mean : `bool`, optional
            When ``True``, the mean vector is subtracted from the data vector.
        square_root : `bool`, optional
            If ``False``, the mahalanobis distance gets squared.
        """
        samples, _ = self._data_to_matrix(samples, None)
        if len(samples.shape) == 1:
            samples = samples[..., None].T
        return self._mahalanobis_distance(samples=samples,
                                          subtract_mean=subtract_mean,
                                          square_root=square_root)
dataset/ETHPy150Open menpo/menpo/menpo/model/gmrf.py/GMRFVectorModel.mahalanobis_distance/original