rand.random_orthonormal_basis¶
Generates a random orthonormal basis.
Functions¶
|
Generate a real random orthonormal basis of given dimension \(d\). |
Module Contents¶
- rand.random_orthonormal_basis.random_orthonormal_basis(dim, is_real=False, seed=None)¶
Generate a real random orthonormal basis of given dimension \(d\).
The basis is generated from the columns of a random unitary matrix of the same dimension as the columns of a unitary matrix typically form an orthonormal basis [1].
Examples
To generate a random orthonormal basis of dimension \(4\),
>>> from toqito.rand import random_orthonormal_basis >>> random_orthonormal_basis(4, is_real = True) [array([0.52188745, 0.4983613 , 0.69049811, 0.04981832]), array([-0.48670459, 0.58756912, -0.10226756, 0.63829658]), array([ 0.23965404, -0.58538248, 0.187136 , 0.75158061]), array([ 0.658269 , 0.25243989, -0.69118291, 0.158815 ])]
It is also possible to add a seed for reproducibility.
>>> from toqito.rand import random_orthonormal_basis >>> random_orthonormal_basis(2, is_real=True, seed=42) [array([0.66954664, 0.74277002]), array([-0.74277002, 0.66954664])]
References
[1]Stack Exchange Mathematics. Why do the columns of a unitary matrix form an orthonormal basis? URL: https://math.stackexchange.com/q/1688950.
- dim: int
Number of elements in the random orthonormal basis.
- seed: int | None
A seed used to instantiate numpy’s random number generator.
- Parameters:
dim (int)
is_real (bool)
seed (int | None)
- Return type:
list[numpy.ndarray]