X-Git-Url: https://code.communitydata.science/coldcallbot-discord.git/blobdiff_plain/35bf83e9f6168af66d16196bf6b455954acaa3e6..78ac188f0487ba413244246181ad90b9a73451d8:/assessment_and_tracking/simulation.R?ds=sidebyside diff --git a/assessment_and_tracking/simulation.R b/assessment_and_tracking/simulation.R new file mode 100644 index 0000000..7134bef --- /dev/null +++ b/assessment_and_tracking/simulation.R @@ -0,0 +1,24 @@ +weight.fac <- 2 +num.calls <- 373 +num.students <- 76 + +gen.calls.per.students <- function (x) { + raw.weights <<- rep(1, num.students) + names(raw.weights) <- seq(1, num.students) + + table(sapply(1:num.calls, function (i) { + probs <- raw.weights / sum(raw.weights) + selected <- sample(names(raw.weights), 1, prob=probs) + ## update the raw.weights + raw.weights[selected] <<- raw.weights[selected] / weight.fac + #print(raw.weights) + return(selected) + })) +} + + +simulated.call.list <- unlist(lapply(1:1000, gen.calls.per.students)) +hist(simulated.call.list) + +quantile(simulated.call.list, probs=seq(0,1,by=0.01)) +quantile(simulated.call.list, probs=0.05)