Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

randortho

Generate Random Orthonormal or Unitary Matrix


Description

Generates random orthonormal or unitary matrix of size n.

Will be needed in applications that explore high-dimensional data spaces, for example optimization procedures or Monte Carlo methods.

Usage

randortho(n, type = c("orthonormal", "unitary"))

Arguments

n

positive integer.

type

orthonormal (i.e., real) or unitary (i.e., complex) matrix.

Details

Generates orthonormal or unitary matrices Q, that is t(Q) resp t(Conj(Q)) is inverse to Q. The randomness is meant with respect to the (additively invariant) Haar measure on O(n) resp. U(n).

Stewart (1980) describes a way to generate such matrices by applying Householder transformation. Here a simpler approach is taken based on the QR decomposition, see Mezzadri (2006),

Value

Orthogonal (or unitary) matrix Q of size n, that is Q %*% t(Q) resp. Q %*% t(Conj(Q)) is the unit matrix of size n.

Note

rortho was deprecated and eventually removed in version 2.1.7.

References

G. W. Stewart (1980). “The Efficient Generation of Random Orthogonal Matrices with an Application to Condition Estimators”. SIAM Journal on Numerical Analysis, Vol. 17, No. 3, pp. 403-409.

F. Mezzadri (2006). “How to generate random matrices from the classical compact groups”. NOTICES of the AMS, Vol. 54 (2007), 592-604. (arxiv.org/abs/math-ph/0609050v2)

Examples

Q <- randortho(5)
zapsmall(Q %*% t(Q))
zapsmall(t(Q) %*% Q)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.