R/Geom_Sim.R

Geom_Sim <-
function(p,n){
  q <- 1-p
  x <- numeric(n)
  for(i in 1:n){
    temp <- runif(1)
    temp <- 1-temp
    j <- 0
    while(((temp>q^j) & (temp <= q^{j-1}))==FALSE)j <- j+1
    x[i] <- j
  }
  return(x)
}

Try the ACSWR package in your browser

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

ACSWR documentation built on May 2, 2019, 6:53 a.m.