1. degree 2. sim3coll <- function(nreps) { countColl <- 0 count3 <- 0 for (rep in 1:nreps) { tmp <- doExpt() nSend <- sum(tmp) if (nSend >= 2) { countColl <- countColl + 1 if (nSend == 3) count3 <- count3 + 1 } } count3 / countColl } doExpt <- function() { trySend <- sample(0:1,3,replace=T,prob=c(0.6,0.4)) } 3. Let Si denote the event that user i sends in that epoch, i = 1,2,3. Then P(S1 and S2 and S3 | S1 and S2 and not S3 or S1 and not S2 and S3 or ...) = 0.4^3 / ( 3 * (0.4)^2 * 0.6 + 0.4^3) 4. # find largest gap maxgap <- function(n,m,k) { tmp <- combn(n,m,checkgap) mean(tmp == k) } checkgap <- function(cmb) { tmp <- diff(c(cmb)) max(tmp) }