R/rhubbell.R

"rhubbell" <-
function(theta, J) 
{
  community <- NULL
  for (j in 0:(J-1)) {
    if (runif(1) < theta/(theta+j))
      community <- c(community, 1)
    else {
      species <- sample(length(community), 1, prob=community/j)
      community[species] <- community[species]+1
    }
  }
  return(community)   
}

Try the hubbell package in your browser

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

hubbell documentation built on May 2, 2019, 5:40 p.m.