R/rfolded.R

Defines functions rfolded

Documented in rfolded

rfolded <- function(n, mu, su, a) {

  z <- Rfast::rmvnorm(n, mu, su)
  D <- dim(z)[2]
  z1 <- z %*% helm(D + 1)
  mi <- abs(a) * Rfast::rowMins(z1, value = TRUE)
  ina <- which(mi <  - 1)
  if ( length(ina) > 0 ) {
    p <- 1 / abs( mi[ina] )
    w <- p^2 * z1[ina, ]
    x1 <- rbind( z1[-ina, ], w )
  } else  x1 <- z1

  if ( abs(a) < 1e-9 )  {  ## if alpha is almost zero make it zero
    z <- exp(x1)
  } else  z <- (a * x1 + 1) ^ (1/a)
    z <- z / Rfast::rowsums(z)
  
  z
}

Try the Compositional package in your browser

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

Compositional documentation built on Oct. 23, 2023, 5:09 p.m.