{ } Raw JSON

bundles / scipy 1.18.0 / scipy / stats / _multivariate / unitary_group_gen

class

scipy.stats._multivariate:unitary_group_gen

source: /scipy/stats/_multivariate.py:4855

Signature

class unitary_group_gen(seed = None)

Members

Summary

A matrix-valued U(N) random variable.

Extended Summary

Return a random unitary matrix.

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 U(N).

Notes

This class is similar to ortho_group.

Examples

import numpy as np
from scipy.stats import unitary_group
x = unitary_group.rvs(3)
✓
np.dot(x, x.conj().T)
✗
array([[ 1.-0.j, -0.-0.j,  0.+0.j],
       [-0.+0.j,  1.-0.j, -0.+0.j],
       [ 0.-0.j, -0.-0.j,  1.-0.j]])
This generates one random matrix from U(3). The dot product confirms that it is unitary up to machine precision. Alternatively, the object may be called (as a function) to fix the `dim` parameter, return a "frozen" unitary_group random variable:
rv = unitary_group(5)
✓

See also

ortho_group

Aliases

  • scipy.stats._multivariate.unitary_group_gen