R/yuleSim.R

`yuleSim` <-
function(ntaxa, nsets, lambda = 0.01)
{
    rmat <- matrix(0, nsets, (ntaxa-1))
    for (i in 1:nsets)
    {
      rmat[i, ] <- rexp(ntaxa-1, rate = lambda*(2:ntaxa))

    }
    #slight problem here, because the final branching time - or the
    #time to present after the birth of the Nth lineage - has a different
    #distribution (exp(-nrt)), rather than exp.

    for (i in 1:nsets)
    {
      rmat[i,] <- rev(cumsum(rmat[i, (ntaxa-1):1]))

    }

    return(rmat)
}

Try the laser package in your browser

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

laser documentation built on Jan. 15, 2017, 4:49 p.m.