# NOT RUN {
# Compare distribution of mean for different sample sizes
mbc(mean(rnorm(1e2)),
mean(rnorm(1e4)),
times=20)
# Compare mean and median on same data
mbc(mean(x),
median(x),
inputi={x=rexp(1e2)})
# input given, no post
mbc({Sys.sleep(rexp(1, 30));mean(x)},
{Sys.sleep(rexp(1, 5));median(x)},
inputi={x=runif(100)})
# input given with post
mbc(mean={Sys.sleep(rexp(1, 30));mean(x)},
med={Sys.sleep(rexp(1, 5));median(x)},
inputi={x=runif(100)},
post=function(x){c(x+1, x^2)})
# input given with post, 30 times
mbc(mean={Sys.sleep(rexp(1, 30));mean(x)+runif(1)},
med={Sys.sleep(rexp(1, 50));median(x)+runif(1)},
inputi={x=runif(100)},
post=function(x){c(x+1, x^2)}, times=10)
# Name one function and post
mbc({mean(x)+runif(1)},
a1={median(x)+runif(1)},
inputi={x=runif(100)},
post=function(x){c(rr=x+1, gg=x^2)}, times=10)
# No input
m1 <- mbc(mean={x <- runif(100);Sys.sleep(rexp(1, 30));mean(x)},
med={x <- runif(100);Sys.sleep(rexp(1, 50));median(x)})
# }
Run the code above in your browser using DataCamp Workspace