random_orthonormal_basis
¶
Generates a random orthonormal basis.
random_orthonormal_basis
¶
random_orthonormal_basis(
dim: int, is_real: bool = False, seed: int | None = None
) -> list[ndarray]
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.
Parameters:
-
dim(int) –Number of elements in the random orthonormal basis.
-
is_real(bool, default:False) –Bool
-
seed(int | None, default:None) –A seed used to instantiate numpy's random number generator.
Examples:
To generate a random orthonormal basis of dimension \(4\),
[array([ 0.3463865 , 0.26523867, 0.33694333, -0.83434647]), array([ 0.61416497, 0.60698551, -0.42082115, 0.27799196]), array([ 0.61546291, -0.74907298, -0.23285148, -0.07665021]), array([ 0.35216924, -0.0103294 , 0.80941889, 0.46979909])]
It is also possible to add a seed for reproducibility.
from toqito.rand import random_orthonormal_basis
print(random_orthonormal_basis(2, is_real=True, seed=42))
References
1 Mathematics, Stack. Why do the columns of a unitary matrix form an orthonormal basis?. link.