R/rU.R

Defines functions rU

Documented in rU

#' @rdname U-utils
#' @export
rU <- function(n, beta, distname, use.mean.variance = TRUE) {
  check_distname(distname)
  names(beta) <- get_beta_names(distname)
  
  sigma.x <- beta2tau(beta, distname = distname,
                      use.mean.variance = use.mean.variance)["sigma_x"]
  switch(distname,
         cauchy = {
           uu <- rcauchy(n)
         },
         chisq = {
           uu <- rchisq(n, df = beta) / sigma.x
         },
         exp = {
           uu <- rexp(n)
         },
         #f = {
        #   #TODO
        # },
         gamma = {
           uu <- rgamma(n, shape = beta["shape"], scale = beta["scale"]) / sigma.x
         },
         laplace = {
           #TODO
         },
         normal = {
           uu <- rnorm(n)
         },
         t = {
           ss<- sigma.x / beta["scale"]
           uu <- rt(n, df = beta["df"]) / ss
         }, 
         unif = {
           uu <- runif(n, -sqrt(3), sqrt(3))
         },
         weibull = {
          uu <- rweibull(n, shape = beta["shape"], scale = beta["scale"]) / sigma.x
        }
  )
  return(uu)
} 

Try the LambertW package in your browser

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

LambertW documentation built on May 29, 2024, 4:30 a.m.