Learn R Programming

pracma (version 1.8.8)

rortho: Generate Random Orthogogonal Matrix

Description

Generates random orthogonal matrix of size n.

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

Usage

rortho(n)

Arguments

n
positive integer.

Value

  • Orthogonal matrix Q of size n, that is Q %*% t(Q) is the unit matrix of size n.

Details

Uses the idea of the Stewart 1980, ``The Efficient Generation of Random Orthogonal Matrices with an Application to Condition Estimators'', to apply the Householder transformation to a uniformly distributed random vector.

Examples

Run this code
Q <- rortho(5)
zapsmall(Q %*% t(Q))
zapsmall(t(Q) %*% Q)

Run the code above in your browser using DataLab