Description Usage Arguments Value Author(s) References Examples
Simulate a random normal vector from the von Mises-Fisher distribution as described in Wood(1994).
1  | rmf.vector(kmu)
 | 
kmu | 
 a vector.  | 
a vector.
Peter Hoff
Wood(1994), 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  | ## The function is currently defined as
function (kmu) 
{
    kap <- sqrt(sum(kmu^2))
    mu <- kmu/kap
    m <- length(mu)
    if (kap == 0) {
        u <- rnorm(length(kmu))
        u<-matrix(u/sqrt(sum(u^2)),m,1) 
    }
    if (kap > 0) {
        if (m == 1) {
            u <- (-1)^rbinom(1, 1, 1/(1 + exp(2 * kap * mu)))
        }
        if (m > 1) {
            W <- rW(kap, m)
            V <- rnorm(m - 1)
            V <- V/sqrt(sum(V^2))
            x <- c((1 - W^2)^0.5 * t(V), W)
            u <- cbind(NullC(mu), mu) %*% x
        }
    }
    u
  }
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.