Skip to content

Instantly share code, notes, and snippets.

simulate <- function(nsim,nvec){
simdx <- c()
for(i in 1:length(nvec))
simdx <- c(simdx,rep(1:nsim,each=nvec[i])+(i-1)*nsim)
dt <- data.table(sim=simdx)
bigN <- nrow(dt)
dt$n <- rep(rep(nvec,nvec),each=nsim)
dt$one <- 1
dt$simc <- dt[,cumsum(one),by=sim]$V1
dt$one <- NULL