R/rfd.R

Defines functions rfd

Documented in rfd

rfd <- function(n, alpha, prob, tau) {
  D <- length(alpha)
  x <- t( rmultinom(n, 1, prob) )
  ind <- Rfast::rowMaxs(x)
  x <- x * rgamma(n, alpha[ind] + tau)

  for (j in 1:D) {
   id <- which( x[, j] == 0 )
   x[id, j] <- rgamma(length(id), alpha[j])
  }
  x / Rfast::rowsums(x)
}

#rfd <- function(n, alpha, prob, tau) {
#  FlexDir::FD.generate(n = n, a = alpha, p = prob, t = tau)
#}

Try the Compositional package in your browser

Any scripts or data that you put into this service are public.

Compositional documentation built on Oct. 9, 2024, 5:10 p.m.