Repository: scipy/scipy
File: scipy/stats/_multivariate.py (Python)

Code before:
            cov = centered_data.T @ centered_data / n_vectors
        return mean, cov

    def marginal(self, dimensions, mean=None, cov=1, allow_singular=False):
        """Return a marginal multivariate normal distribution

        Parameters
        ----------
        dimensions : int or 1-d array_like
            The dimensions of the multivariate distribution corresponding
            with the marginal variables, that is, the indices of the dimensions
            that are being retained. The other dimensions are marginalized out.

        Returns
        -------
        marginal_multivariate_normal : multivariate_normal_frozen
            An object representing the marginal distribution.
        """
        params = self._process_parameters(mean, cov, allow_singular)
        n, mean, cov_object = params
        dims = _validate_marginal_input(dimensions, n)

        mean = mean[dims]
        cov = cov_object.covariance[np.ix_(dims, dims)]
        
        return multivariate_normal_frozen(mean, cov, allow_singular)    

multivariate_normal = multivariate_normal_gen()


class multivariate_normal_frozen(multi_rv_frozen):
    __class_getitem__ = None

    def __init__(self, mean=None, cov=1, allow_singular=False, seed=None,
                 maxpts=None, abseps=1e-5, releps=1e-5):
        """Create a frozen multivariate normal distribution.

        Parameters
        ----------
        mean : array_like, default: ``[0]``
            Mean of the distribution.
        cov : array_like, default: ``[1]``
            Symmetric positive (semi)definite covariance matrix of the
            distribution.
        allow_singular : bool, default: ``False``
            Whether to allow a singular covariance matrix.
        seed : {None, int, `numpy.random.Generator`, `numpy.random.RandomState`}, optional
            If `seed` is None (or `np.random`), the `numpy.random.RandomState`
            singleton is used.
            If `seed` is an int, a new ``RandomState`` instance is used,
            seeded with `seed`.

Review comment (suggestion):
```suggestion
        return multivariate_normal_frozen(mean, cov, allow_singular)
```

Code after:
            centered_data = x - mean
            cov = centered_data.T @ centered_data / n_vectors
        return mean, cov

    def marginal(self, dimensions, mean=None, cov=1, allow_singular=False):
        """Return a marginal multivariate normal distribution.

        Parameters
        ----------
        dimensions : int or 1-d array_like
            The dimensions of the multivariate distribution corresponding
            with the marginal variables, that is, the indices of the dimensions
            that are being retained. The other dimensions are marginalized out.
        %(_mvn_doc_default_callparams)s

        Returns
        -------
        marginal_multivariate_normal : multivariate_normal_frozen
            An object representing the marginal distribution.
        
        Notes
        -----
        %(_mvn_doc_callparams_note)s
        """
        params = self._process_parameters(mean, cov, allow_singular)
        n, mean, cov_object = params
        dims = _validate_marginal_input(dimensions, n)

        mean = mean[dims]
        cov = cov_object.covariance[np.ix_(dims, dims)]
        
        return multivariate_normal_frozen(mean, cov, allow_singular)

multivariate_normal = multivariate_normal_gen()


class multivariate_normal_frozen(multi_rv_frozen):
    __class_getitem__ = None

    def __init__(self, mean=None, cov=1, allow_singular=False, seed=None,
                 maxpts=None, abseps=1e-5, releps=1e-5):
        """Create a frozen multivariate normal distribution.

        Parameters
        ----------
        mean : array_like, default: ``[0]``
            Mean of the distribution.
        cov : array_like, default: ``[1]``
            Symmetric positive (semi)definite covariance matrix of the
            distribution.
        allow_singular : bool, default: ``False``