Description Usage Arguments Value Note Author(s) References Examples
View source: R/rbmf.matrix.gibbs.R
Simulate a random orthonormal matrix from the Bingham distribution using Gibbs sampling.
1 | rbmf.matrix.gibbs(A, B, C, X)
|
A |
a symmetric matrix. |
B |
a diagonal matrix with decreasing entries. |
C |
a matrix with the same dimension as X. |
X |
the current value of the random orthonormal matrix. |
a new value of the matrix X
obtained by Gibbs sampling.
This provides one Gibbs scan. The function should be used iteratively.
Peter Hoff
Hoff(2009)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## The function is currently defined as
function (A, B, C, X)
{
m <- dim(X)[1]
R <- dim(X)[2]
if (m > R) {
for (r in sample(seq(1, R, length = R))) {
N <- NullC(X[, -r])
An <- B[r, r] * t(N) %*% (A) %*% N
cn <- t(N) %*% C[, r]
X[, r] <- N %*% rbmf.vector.gibbs(An, cn, t(N) %*%
X[, r])
}
}
if (m == R) {
for (s in seq(1, R, length = R)) {
r <- sort(sample(seq(1, R, length = R), 2))
N <- NullC(X[, -r])
An <- t(N) %*% A %*% N
Cn <- t(N) %*% C[, r]
X[, r] <- N %*% rbmf.O2(An, B[r, r], Cn)
}
}
X
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.