scipy.stats.ortho_group¶
-
scipy.stats.
ortho_group
= <scipy.stats._multivariate.ortho_group_gen object>[source]¶ A matrix-valued O(N) random variable.
Return a random orthogonal matrix, drawn from the O(N) Haar distribution (the only uniform distribution on O(N)).
The dim keyword specifies the dimension N.
Parameters: dim : scalar
Dimension of matrices
Notes
This class is closely related to
special_ortho_group
.Some care is taken to avoid numerical error, as per the paper by Mezzadri.
References
[R645] F. Mezzadri, “How to generate random matrices from the classical compact groups”, arXiv:math-ph/0609050v2. Examples
>>> from scipy.stats import ortho_group >>> x = ortho_group.rvs(3)
>>> np.dot(x, x.T) array([[ 1.00000000e+00, 1.13231364e-17, -2.86852790e-16], [ 1.13231364e-17, 1.00000000e+00, -1.46845020e-16], [ -2.86852790e-16, -1.46845020e-16, 1.00000000e+00]])
>>> import scipy.linalg >>> np.fabs(scipy.linalg.det(x)) 1.0
This generates one random matrix from O(3). It is orthogonal and has a determinant of +1 or -1.
Methods
rvs(dim=None, size=1, random_state=None)
Draw random samples from O(N).