randorth | R Documentation |
Generation of a random orthogonal n x n
matrix.
randorth(n, type = c("orthonormal", "unitary"), I.matrix = FALSE)
n |
|
type |
Either |
I.matrix |
If |
A random orthogonal matrix R
is generated in order that t(R)
(for "orthonormal"
) or Conj(t(R))
(for "unitary"
) equals the inverse matrix of R
.
This function was adapted from the pracma package (pracma::randortho
).
The random orthogonal matrices are distributed with Haar measure over
O(n)
, where O(n)
is the set of orthogonal matrices of order n
.
The random orthogonal matrices are basically distributed "uniformly" in the
space of random orthogonal matrices of dimension n x n
.
See also the Examples
and \insertCiteStewart1980a,Mezzadri2007randRotation.
A random orthogonal matrix of dimension n x n
.
Peter Hettegger
# The following example shows the orthogonality of the random orthogonal matrix:
R1 <- randorth(4)
zapsmall(t(R1) %*% R1)
R1 <- randorth(4, "unitary")
zapsmall(Conj(t(R1)) %*% R1)
# The following example shows the distribution of 2-dimensional random orthogonal vectors
# on the unit circle.
tmp1 <- vapply(1:400, function(i)randorth(2)[,1], numeric(2))
plot(t(tmp1), xlab = "x", ylab = "y")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.