[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r20639: {} Do a quick study on our parameters for discarding circuit ti (torflow/trunk/CircuitAnalysis/BuildTimes)
Author: mikeperry
Date: 2009-09-21 21:27:59 -0400 (Mon, 21 Sep 2009)
New Revision: 20639
Added:
torflow/trunk/CircuitAnalysis/BuildTimes/binomial.py
Log:
Do a quick study on our parameters for discarding circuit
times.
Added: torflow/trunk/CircuitAnalysis/BuildTimes/binomial.py
===================================================================
--- torflow/trunk/CircuitAnalysis/BuildTimes/binomial.py (rev 0)
+++ torflow/trunk/CircuitAnalysis/BuildTimes/binomial.py 2009-09-22 01:27:59 UTC (rev 20639)
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+#
+# Uses the binomial distribution to estimate the expected number of
+# circuit trials before a false positive that discards all of our
+# circuits for a few different parameters.
+
+
+import math
+
+def fact(n):
+ if n==1: return 1
+ return n*fact(n-1)
+
+def choose(n, k): return fact(n)/(fact(k)*fact(n-k))
+def binomial(p, n, k): return choose(n,k)*math.pow(p,k)*math.pow(1-p,n-k)
+
+def BinomialF(p, n, k):
+ F = 0.0
+ for i in xrange(k,n): F+=binomial(p,n,i)
+ return F
+
+twenty_pct = BinomialF(.2, 20, 15)
+fifty_pct = BinomialF(.5, 20, 15)
+
+print "15 out of 20:"
+print "20% circ timeout rate expects: "+str(1.0/twenty_pct)+" trials"
+print "50% circ timeout rate expects: "+str(1.0/fifty_pct)+" trials"
+print
+
+twenty_pct = BinomialF(.2, 20, 16)
+fifty_pct = BinomialF(.5, 20, 16)
+
+print "16 out of 20:"
+print "20% circ timeout rate expects: "+str(1.0/twenty_pct) +" trials"
+print "50% circ timeout rate expects: "+str(1.0/fifty_pct)+" trials"
+print
+
+twenty_pct = BinomialF(.2, 20, 18)
+fifty_pct = BinomialF(.5, 20, 18)
+
+print "18 out of 20:"
+print "20% circ timeout rate expects: "+str(1.0/twenty_pct)+" trials"
+print "50% circ timeout rate expects: "+str(1.0/fifty_pct)+" trials"
+print
Property changes on: torflow/trunk/CircuitAnalysis/BuildTimes/binomial.py
___________________________________________________________________
Added: svn:executable
+ *