# NOT RUN {
# for following problem size the rank-based algo
# outperforms the quantile based one, although,
# ran serially
mat <- matrix(rnorm(10000*100), ncol=100)
mat <- t(apply(mat, 1, sort))
system.time(stb.rank <- rankSTB(mat))
system.time(stb.q.R <- getSTB(mat))
system.time(stb.q.C <- fastSTB(mat))
x <- apply(mat, 2, mean)
plot(x,x, ylim=c(-5,5))
lines(x, stb.q.R$Q[1,], col="blue", lwd=2)
lines(x, stb.q.R$Q[2,], col="blue", lwd=2)
lines(x, stb.q.C$Q[1,], col="red", lwd=2)
lines(x, stb.q.C$Q[2,], col="red", lwd=2)
lines(x, stb.rank$Q[1,], col="cyan", lwd=2)
lines(x, stb.rank$Q[2,], col="cyan", lwd=2)
legend("top", legend=c("R-quantile", "C-quantile", "rank-based"),
fill=c("blue", "red", "cyan"))
# varying Ncpu for the C-implementation of the quantile-based algo
system.time(stb.q.C <- fastSTB(mat, Ncpu=4))
system.time(stb.q.C <- fastSTB(mat, Ncpu=6))
system.time(stb.q.C <- fastSTB(mat, Ncpu=8))
system.time(stb.q.C <- fastSTB(mat, Ncpu=10))
system.time(stb.q.C <- fastSTB(mat, Ncpu=12))
# }
Run the code above in your browser using DataLab