summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Murdoch <Steven.Murdoch@cl.cam.ac.uk>2008-12-24 16:00:47 +0000
committerSteven Murdoch <Steven.Murdoch@cl.cam.ac.uk>2008-12-24 16:00:47 +0000
commit294e773ae9ca4dc3cb0aaabb527eea7f2916d9e5 (patch)
tree579b7e13d9ed3a372ce0bdbc5e705ab639510419
parent5dd7e018cb1bf3569458fcd020ba5170a47bf1ef (diff)
downloadtor-294e773ae9ca4dc3cb0aaabb527eea7f2916d9e5.tar.gz
tor-294e773ae9ca4dc3cb0aaabb527eea7f2916d9e5.zip
Add R code for plotting optimized node selection probabilities
svn:r17761
-rw-r--r--doc/design-paper/node-selection/plot-node-selection.R56
1 files changed, 56 insertions, 0 deletions
diff --git a/doc/design-paper/node-selection/plot-node-selection.R b/doc/design-paper/node-selection/plot-node-selection.R
new file mode 100644
index 0000000000..3559c5381f
--- /dev/null
+++ b/doc/design-paper/node-selection/plot-node-selection.R
@@ -0,0 +1,56 @@
+## Load in data files
+t1 = read.table("opt_1e-6.pickle.dat", header=TRUE)
+t2 = read.table("opt_1e-3.pickle.dat", header=TRUE)
+t3 = read.table("opt_1e-1.pickle.dat", header=TRUE)
+t4 = read.table("opt_0.75.pickle.dat", header=TRUE)
+t5 = read.table("opt_0.5.pickle.dat", header=TRUE)
+t6 = read.table("opt_0.25.pickle.dat", header=TRUE)
+t7 = read.table("opt_0.1.pickle.dat", header=TRUE)
+tt = read.table("opt_tor.pickle.dat", header=TRUE)
+
+## Calculate selection probabilties that Tor uses
+o = t1$bw/sum(t1$bw)
+
+#plot(t1$bw, cumsum(t1$prob), col="red", type="l")
+#lines(t1$bw, cumsum(t2$prob), col="pink")
+#lines(t1$bw, cumsum(t3$prob), col="blue")
+#lines(t1$bw, cumsum(t4$prob), col="orange")
+#lines(t1$bw, cumsum(t5$prob), col="purple")
+#lines(t1$bw, cumsum(tt$prob))
+
+## Plot probabiltieis
+pdf("optimum-selection-probabilities.pdf")
+col <- rainbow(8)
+ plot(t1$bw, t1$prob, col=col[1], type="b", ylim=c(0,0.035),xlab="Bandwidth (cells/s)",
+ ylab="Selection probability", frame.plot=FALSE)
+lines(t1$bw, t2$prob, col=col[2], type="b")
+lines(t1$bw, t3$prob, col=col[3], type="b")
+lines(t1$bw, t4$prob, col=col[4], type="b")
+lines(t1$bw, t5$prob, col=col[5], type="b")
+
+## These are too messy
+##lines(t1$bw, t6$prob, col=col[6], type="b")
+##lines(t1$bw, t7$prob, col=col[7], type="b")
+
+lines(t1$bw, tt$prob,col=col[8], type="b")
+lines(t1$bw, o, type="l", lwd=2)
+
+## Annotate graph
+title(main="Optimum node selection probability")
+x <- rep(8254.383, 4)
+y <- c(0.03453717, 0.02553347, 0.02219589, 0.02048830)
+par(xpd=TRUE)
+text(x,y,c("50%", "75%", "90%", ">99%"), adj=c(0,0.5))
+dev.off()
+
+## Plot probabilities relative to what Tor does
+pdf("relative-selection-probabilities.pdf")
+ plot(t1$bw, t1$prob-o, col=col[1], type="b", xlab="Bandwidth (cells/s)",
+ ylab="Selection probability - Tor's selection probability", frame.plot=FALSE, ylim=c(-0.002,0.015))
+lines(t1$bw, t2$prob-o, col=col[2], type="b")
+lines(t1$bw, t3$prob-o, col=col[3], type="b")
+lines(t1$bw, t4$prob-o, col=col[4], type="b")
+lines(t1$bw, t5$prob-o, col=col[5], type="b")
+lines(t1$bw, tt$prob-o,col=col[8], type="b")
+title(main="Selection probabilility compared to Tor")
+dev.off()