pyriemann.datasets.sample_gaussian_spd(n_matrices, mean, sigma, random_state=None, n_jobs=1, sampling_method='auto')

Sample a Riemannian Gaussian distribution.

Sample SPD matrices from a Riemannian Gaussian distribution centered at mean and with dispersion parametrized by sigma. This distribution has been defined in [1] and generalizes the notion of a Gaussian distribution to the space of SPD matrices. The sampling is based on a spectral factorization of SPD matrices in terms of their eigenvectors (U-parameters) and the log of the eigenvalues (r-parameters).


How many matrices to generate.

meanndarray, shape (n_dim, n_dim)

Center of the Riemannian Gaussian distribution.


Dispersion of the Riemannian Gaussian distribution.

random_stateint, RandomState instance or None, default=None

Pass an int for reproducible output across multiple function calls.

n_jobsint, default=1

The number of jobs to use for the computation. This works by computing each of the class centroid in parallel. If -1 all CPUs are used.

sampling_methodstr, default=’auto’

Sampling method to sample eigenvalues. It can be ‘auto’, ‘slice’ or ‘rejection’. If it is ‘auto’, the sampling_method will be equal to ‘slice’ for n_dim != 2 and equal to ‘rejection’ for n_dim = 2.

New in version 0.3.1.

samplesndarray, shape (n_matrices, n_dim, n_dim)

Samples of the Riemannian Gaussian distribution.


New in version 0.3.



Riemannian Gaussian distributions on the space of symmetric positive definite matrices S. Said, L. Bombrun, Y. Berthoumieu, and J. Manton. IEEE Trans Inf Theory, vol. 63, pp. 2153–2170, 2017.