[tor-commits] [metrics-tasks/master] Update #6443 graphing code.

karsten at torproject.org karsten at torproject.org
Wed Jul 25 15:09:26 UTC 2012


commit a1a80237e29fb46101ecfdf126ecbe6f02e0ade1
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Wed Jul 25 17:09:00 2012 +0200

    Update #6443 graphing code.
---
 task-6443/.gitignore          |    4 +++
 task-6443/cumulated-weights.R |   47 ++++++++++++++++++++++++++++++++++-------
 2 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/task-6443/.gitignore b/task-6443/.gitignore
new file mode 100644
index 0000000..6a3a120
--- /dev/null
+++ b/task-6443/.gitignore
@@ -0,0 +1,4 @@
+*.csv
+*.pdf
+*.png
+
diff --git a/task-6443/cumulated-weights.R b/task-6443/cumulated-weights.R
index 50d0f4c..c324acb 100755
--- a/task-6443/cumulated-weights.R
+++ b/task-6443/cumulated-weights.R
@@ -2,10 +2,40 @@ require(ggplot2)
 require(scales)
 require(reshape)
 
-c <- read.csv("cumulated-weights.csv")
-c <- c[c$top_relays %in% c(1, 2, 3, 5, 10, 15, 20, 30, 50), ]
+cw <- read.csv("cumulated-weights.csv", stringsAsFactors = FALSE)
+v <- sort(as.POSIXlt(unique(cw$validafter), tz = "UTC"),
+  decreasing = TRUE)
+now <- week <- month <- threemonths <- year <- v[1]
+week$mday <- week$mday - 7
+month$mon <- month$mon - 1
+threemonths$mon <- threemonths$mon - 3
+year$year <- year$year - 1
+v <- c(
+  format((v[v <= year])[1], usetz = FALSE),
+  format((v[v <= threemonths])[1], usetz = FALSE),
+  format((v[v <= month])[1], usetz = FALSE),
+  format((v[v <= week])[1], usetz = FALSE),
+  format(now, usetz = FALSE))
+v <- cw[cw$validafter %in% v, ]
+v <- data.frame(x = v$top_relays, y = v$total_exit_probability,
+  colour = factor(v$validafter, levels = rev(levels(factor(v$validafter)))))
+ggplot(v, aes(x = x, y = y, colour = colour)) +
+geom_point() +
+geom_line() +
+scale_x_continuous(name = "\nTop-x relays by exit probability") +
+scale_y_continuous(name = "Total exit probability\n", labels = percent) +
+scale_colour_hue(name = "",
+  labels = c(format(as.Date(now), format = "%B %d, %Y"), "1 week before",
+  "1 month before", "3 months before", "1 year before")) +
+opts(title = paste("Probability of selecting one of the top-x relays for",
+  "the exit position\n"))
+ggsave("exit-probability-cdf-a.png", width = 8, height = 5, dpi = 100)
+
+c <- cw
+c <- c[c$top_relays %in% c(1, 2, 5, 10, 20, 50), ]
 c <- aggregate(list(total_exit_probability = c$total_exit_probability),
-  by = list(date = as.Date(c$validafter, origin = "1970-01-01 00:00:00"),
+  by = list(date = as.Date(cut.Date(as.Date(c$validafter,
+  origin = "1970-01-01 00:00:00"), "week")),
   top_relays = c$top_relays), FUN = mean)
 ggplot(c, aes(x = date, y = total_exit_probability,
   colour = as.factor(top_relays))) +
@@ -16,12 +46,13 @@ scale_y_continuous(name = "Total exit probability of top-x relays\n",
 scale_colour_hue(name = "Top-x relays by exit probability") +
 opts(title = paste("Probability of selecting one of the top-x relays for",
   "the exit position\n"), legend.position = "bottom")
-ggsave("exit-probability-cdf.png", width = 8, height = 5, dpi = 100)
+ggsave("exit-probability-cdf-b.png", width = 8, height = 5, dpi = 100)
 
-i <- read.csv("inverse-cumulated-weights.csv")
-i <- i[i$total_exit_probability > 0.1 & i$total_exit_probability < 0.9, ]
+i <- read.csv("inverse-cumulated-weights.csv", stringsAsFactors = FALSE)
+i <- i[i$total_exit_probability %in% factor(c(0.3, 0.4, 0.5, 0.6, 0.7)), ]
 i <- aggregate(list(top_relays = i$top_relays),
-  by = list(date = as.Date(i$validafter, origin = "1970-01-01 00:00:00"),
+  by = list(date = as.Date(cut.Date(as.Date(i$validafter,
+  origin = "1970-01-01 00:00:00"), "week")),
   total_exit_probability = i$total_exit_probability), FUN = mean)
 ggplot(i, aes(x = date, y = top_relays,
   colour = paste(100 * total_exit_probability, "%", sep = ""))) +
@@ -31,5 +62,5 @@ scale_y_continuous(name = "Top-x relays by exit probability\n") +
 scale_colour_hue(name = "Total exit probability of top-x relays") +
 opts(title = paste("Number of relays making up the top-x for a given",
   "total exit probability\n"), legend.position = "bottom")
-ggsave("exit-probability-icdf.png", width = 8, height = 5, dpi = 100)
+ggsave("exit-probability-cdf-c.png", width = 8, height = 5, dpi = 100)
 



More information about the tor-commits mailing list