chanceerror <-function(s) ## n is the number of draws, s is the box we are sampling from { u=seq(10,10000,by=100) n=length(u) ce=numeric(n) cef=ce i=1 for(k in u) { v=sample(s,k,replace=TRUE) ce[i]<-sum(v>0)-k/2 cef[i]<-(sum(v>0)-k/2)/k i <- i+1 } return(list(ce=ce,cef=cef)) }