R/rtpxg.R

Defines functions rtpxg

Documented in rtpxg

rtpxg <- function(n, alpha = 1, theta = 1) {
  x <- numeric(n)                    
  cond <- theta / (alpha + theta)     
  q <- Rfast2::Runif(n)
  exp_ind <- q <= cond
  size1 <- sum(exp_ind)
  x[exp_ind] <- rexp(size1, theta)
  x[!exp_ind] <- rgamma(n - size1, 3, theta)
  x
}

Try the TPXG package in your browser

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

TPXG documentation built on April 3, 2025, 10:37 p.m.