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) –Boolean denoting whether the returned basis vectors will have all real entries or not.
-
seed(int | None, default:None) –A seed used to instantiate numpy's random number generator.
Returns:
-
list[ndarray]–A list of
dimorthonormal basis vectors, each of dimensiondim.
Examples:
To generate a random orthonormal basis of dimension \(4\),
[array([ 0.07861349, 0.42600218, 0.80452385, -0.4063046 ]), array([-0.43084736, -0.02521638, -0.36185678, -0.82631371]), array([ 0.45343798, -0.80462765, 0.22499045, -0.31039915]), array([ 0.77626315, 0.41286876, -0.41373945, -0.23616643])]
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.