5 gen.calls.per.students <- function (x) {
6 raw.weights <<- rep(1, num.students)
7 names(raw.weights) <- seq(1, num.students)
9 table(sapply(1:num.calls, function (i) {
10 probs <- raw.weights / sum(raw.weights)
11 selected <- sample(names(raw.weights), 1, prob=probs)
12 ## update the raw.weights
13 raw.weights[selected] <<- raw.weights[selected] / weight.fac
20 simulated.call.list <- unlist(lapply(1:1000, gen.calls.per.students))
21 hist(simulated.call.list)
23 quantile(simulated.call.list, probs=seq(0,1,by=0.01))
24 quantile(simulated.call.list, probs=0.05)