[metrics-tasks/master] Add graph with single relay probabilities (#1854).

commit 7d94e96a9989342b7dd3a78705cfd41a9611853f Author: Karsten Loesing <karsten.loesing@gmx.net> Date: Tue Nov 27 10:41:14 2012 -0500 Add graph with single relay probabilities (#1854). --- task-1854/plot-entropy.R | 29 ++++++++++++++++++++++++++--- task-1854/pylinf.py | 13 ++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/task-1854/plot-entropy.R b/task-1854/plot-entropy.R index 5d30583..cc963e4 100644 --- a/task-1854/plot-entropy.R +++ b/task-1854/plot-entropy.R @@ -3,7 +3,7 @@ library(reshape) library(scales) p <- read.csv("prob-extracted.csv", header = FALSE, - col.names = c("validafter", "minadvbw", "advbw", "cumprob"), + col.names = c("validafter", "minadvbw", "advbw", "cumprob", "prob"), stringsAsFactor = FALSE) p <- p[p$minadvbw >= 20480, ] c <- data.frame(x = p$advbw, y = p$cumprob, @@ -13,14 +13,37 @@ geom_line() + scale_x_log10(name = "\nAdvertised bandwidth in B/s (log scale)") + scale_y_continuous(name = "Cumulative probability\n") + scale_colour_hue(name = "Adv. bw. cutoff in B/s") + -opts(legend.position = "top") +opts(title = paste("Consensus with valid-after time", max(p$validafter)), + legend.position = "top") ggplot(c, aes(x = x, y = y, colour = colour)) + geom_line() + scale_x_log10(name = "\nAdvertised bandwidth in B/s (log scale)") + scale_y_log10(name = "Cumulative probability (log scale)\n") + scale_colour_hue(name = "Adv. bw. cutoff in B/s") + -opts(legend.position = "top") +opts(title = paste("Consensus with valid-after time", max(p$validafter)), + legend.position = "top") + +p <- p[p$minadvbw == 20480 | p$minadvbw == 1048576, ] +c <- data.frame(x = p$advbw, y = p$prob, + colour = as.factor(p$minadvbw)) +ggplot(c, aes(x = x, y = y, colour = colour)) + +geom_point(alpha = 0.25) + +scale_x_log10(name = "\nAdvertised bandwidth in B/s (log scale)") + +scale_y_continuous(name = paste("Single relay probability, *not*", + "probability distribution function\n")) + +scale_colour_hue(name = "Advertised bandwidth cutoff in B/s") + +opts(title = paste("Consensus with valid-after time", max(p$validafter)), + legend.position = "top") + +ggplot(c, aes(x = x, y = y, colour = colour)) + +geom_point(alpha = 0.25) + +scale_x_log10(name = "\nAdvertised bandwidth in B/s (log scale)") + +scale_y_log10(name = paste("Single relay probability, *not*", + "probability distribution function (log scale)\n")) + +scale_colour_hue(name = "Advertised bandwidth cutoff in B/s") + +opts(title = paste("Consensus with valid-after time", max(p$validafter)), + legend.position = "top") e <- read.csv("linf-extracted.csv", header = FALSE, col.names = c("validafter", "min_adv_bw", "relays", "linf", diff --git a/task-1854/pylinf.py b/task-1854/pylinf.py index 9885de5..15833e6 100644 --- a/task-1854/pylinf.py +++ b/task-1854/pylinf.py @@ -168,8 +168,8 @@ def run(data): str(len(routers)-omitted_routers), str(max(prob_diff))])) - while len(cutoffs) > 0 and min_adv_bw > cutoffs[0]: - cumulated_prob = 0.0 + while len(cutoffs) > 0 and min_adv_bw >= cutoffs[0]: + prev_prob, cumulated_prob = 0.0, 0.0 prev_advertised_bw = 0 for router in routers: if router.advertised_bw > cutoffs[0] and \ @@ -177,13 +177,16 @@ def run(data): prob_string.append(','.join([valid_after, str(cutoffs[0]), str(prev_advertised_bw), - str(cumulated_prob)])) + str(cumulated_prob), + str(prev_prob)])) prev_advertised_bw = router.advertised_bw - cumulated_prob += float(router.bandwidth)/float(total_bw) + prev_prob = float(router.bandwidth)/float(total_bw) + cumulated_prob += prev_prob prob_string.append(','.join([valid_after, str(cutoffs[0]), str(prev_advertised_bw), - str(cumulated_prob)])) + str(cumulated_prob), + str(prev_prob)])) cutoffs.pop(0) # remove routers with min adv_bw
participants (1)
-
karsten@torproject.org