This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / stats / _multivariate / ortho_group_gen

class

scipy.stats._multivariate:ortho_group_gen

source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_multivariate.py:4426

Signature

class ortho_group_gen(seed = None)

Members

Summary

An Orthogonal matrix (O(N)) random variable.

Extended Summary

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

seed : {None, int, np.random.RandomState, np.random.Generator}, optional

Used for drawing random variates. If seed is None, the ~np.random.RandomState singleton is used. If seed is an int, a new RandomState instance is used, seeded with seed. If seed is already a RandomState or Generator instance, then that object is used. Default is None.

Methods

rvs(dim=None, size=1, random_state=None)

Draw random samples from O(N).

Notes

This class is closely related to special_ortho_group.

Some care is taken to avoid numerical error, as per the paper by Mezzadri.

Examples

import numpy as np
from scipy.stats import ortho_group
x = ortho_group.rvs(3)
✓
np.dot(x, x.T)
✗
array([[ 1.,  0.,  0.],
       [ 0.,  1., -0.],
       [ 0., -0.,  1.]])
import scipy.linalg
✓
np.fabs(scipy.linalg.det(x))
✗
np.float64(0.9999999999999998)
This generates one random matrix from O(3). It is orthogonal and has a determinant of +1 or -1. Alternatively, the object may be called (as a function) to fix the `dim` parameter, returning a "frozen" ortho_group random variable:
rv = ortho_group(5)
✓

See also

special_ortho_group

Aliases

  • scipy.stats._multivariate.ortho_group_gen