[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [torflow/master] Add additional binomial formula scripts for reference.



Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Thu, 24 Jun 2010 20:17:34 -0700
Subject: Add additional binomial formula scripts for reference.
Commit: 088b375dc047e0688b4c466bac03cbf00aa24e87

---
 CircuitAnalysis/BuildTimes/binomial-10.py |   80 +++++++++++++++++++++++++++++
 CircuitAnalysis/BuildTimes/binomial-15.py |   80 +++++++++++++++++++++++++++++
 CircuitAnalysis/BuildTimes/binomial-20.py |   80 +++++++++++++++++++++++++++++
 CircuitAnalysis/BuildTimes/binomial.py    |   68 ------------------------
 4 files changed, 240 insertions(+), 68 deletions(-)
 create mode 100755 CircuitAnalysis/BuildTimes/binomial-10.py
 create mode 100755 CircuitAnalysis/BuildTimes/binomial-15.py
 create mode 100755 CircuitAnalysis/BuildTimes/binomial-20.py
 delete mode 100755 CircuitAnalysis/BuildTimes/binomial.py

diff --git a/CircuitAnalysis/BuildTimes/binomial-10.py b/CircuitAnalysis/BuildTimes/binomial-10.py
new file mode 100755
index 0000000..6d3d9c7
--- /dev/null
+++ b/CircuitAnalysis/BuildTimes/binomial-10.py
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+#
+# Uses the binomial distribution to estimate the expected number of
+# circuit 10-circ groups before a false positive that discards all of our
+# 10-circ groups 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, 10, 7)
+thirty_pct = BinomialF(.35, 10, 7)
+fourty_pct = BinomialF(.4, 10, 7)
+fifty_pct = BinomialF(.5, 10, 7)
+sixty_pct = BinomialF(.6, 10, 7)
+seventy_pct = BinomialF(.7, 10, 7)
+eighty_pct = BinomialF(.8, 10, 7)
+ninety_pct = BinomialF(.9, 10, 7)
+
+print "7 out of 10:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 10-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 10-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 10-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 10-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 10-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 10-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
+
+twenty_pct = BinomialF(.2, 10, 8)
+thirty_pct = BinomialF(.3, 10, 8)
+fourty_pct = BinomialF(.4, 10, 8)
+fifty_pct = BinomialF(.5, 10, 8)
+sixty_pct = BinomialF(.6, 10, 8)
+seventy_pct = BinomialF(.7, 10, 8)
+eighty_pct = BinomialF(.8, 10, 8)
+ninety_pct = BinomialF(.9, 10, 8)
+
+print "8 out of 10:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct) +" 10-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 10-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 10-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 10-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 10-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 10-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
+
+twenty_pct = BinomialF(.2, 10, 9)
+thirty_pct = BinomialF(.30, 10, 9)
+fourty_pct = BinomialF(.40, 10, 9)
+fifty_pct = BinomialF(.5, 10, 9)
+sixty_pct = BinomialF(.6, 10, 9)
+seventy_pct = BinomialF(.7, 10, 9)
+eighty_pct = BinomialF(.8, 10, 9)
+ninety_pct = BinomialF(.9, 10, 9)
+
+print "9 out of 10:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 10-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 10-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 10-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 10-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 10-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 10-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
diff --git a/CircuitAnalysis/BuildTimes/binomial-15.py b/CircuitAnalysis/BuildTimes/binomial-15.py
new file mode 100755
index 0000000..cb3425f
--- /dev/null
+++ b/CircuitAnalysis/BuildTimes/binomial-15.py
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+#
+# Uses the binomial distribution to estimate the expected number of
+# circuit 15-circ groups before a false positive that discards all of our
+# 15-circ groups 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, 15, 12)
+thirty_pct = BinomialF(.3, 15, 12)
+fourty_pct = BinomialF(.4, 15, 12)
+fifty_pct = BinomialF(.5, 15, 12)
+sixty_pct = BinomialF(.6, 15, 12)
+seventy_pct = BinomialF(.7, 15, 12)
+eighty_pct = BinomialF(.8, 15, 12)
+ninety_pct = BinomialF(.9, 15, 12)
+
+print "12 out of 15:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 15-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 15-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 15-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 15-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 15-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 15-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
+
+twenty_pct = BinomialF(.2, 15, 13)
+thirty_pct = BinomialF(.3, 15, 13)
+fourty_pct = BinomialF(.4, 15, 13)
+fifty_pct = BinomialF(.5, 15, 13)
+sixty_pct = BinomialF(.6, 15, 13)
+seventy_pct = BinomialF(.7, 15, 13)
+eighty_pct = BinomialF(.8, 15, 13)
+ninety_pct = BinomialF(.9, 15, 13)
+
+print "13 out of 15:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct) +" 15-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 15-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 15-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 15-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 15-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 15-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
+
+twenty_pct = BinomialF(.2, 15, 14)
+thirty_pct = BinomialF(.3, 15, 14)
+fourty_pct = BinomialF(.4, 15, 14)
+fifty_pct = BinomialF(.5, 15, 14)
+sixty_pct = BinomialF(.6, 15, 14)
+seventy_pct = BinomialF(.7, 15, 14)
+eighty_pct = BinomialF(.8, 15, 14)
+ninety_pct = BinomialF(.9, 15, 14)
+
+print "14 out of 15:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 15-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 15-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 15-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 15-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 15-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 15-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
diff --git a/CircuitAnalysis/BuildTimes/binomial-20.py b/CircuitAnalysis/BuildTimes/binomial-20.py
new file mode 100755
index 0000000..1d50cec
--- /dev/null
+++ b/CircuitAnalysis/BuildTimes/binomial-20.py
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+#
+# Uses the binomial distribution to estimate the expected number of
+# circuit 20-circ groups before a false positive that discards all of our
+# 20-circ groups 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, 16)
+thirty_pct = BinomialF(.3, 20, 16)
+fourty_pct = BinomialF(.4, 20, 16)
+fifty_pct = BinomialF(.5, 20, 16)
+sixty_pct = BinomialF(.6, 20, 16)
+seventy_pct = BinomialF(.7, 20, 16)
+eighty_pct = BinomialF(.8, 20, 16)
+ninety_pct = BinomialF(.9, 20, 16)
+
+print "16 out of 20:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 20-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 20-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 20-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 20-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 20-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 20-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
+
+twenty_pct = BinomialF(.2, 20, 17)
+thirty_pct = BinomialF(.3, 20, 17)
+fourty_pct = BinomialF(.4, 20, 17)
+fifty_pct = BinomialF(.5, 20, 17)
+sixty_pct = BinomialF(.6, 20, 17)
+seventy_pct = BinomialF(.7, 20, 17)
+eighty_pct = BinomialF(.8, 20, 17)
+ninety_pct = BinomialF(.9, 20, 17)
+
+print "17 out of 20:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct) +" 20-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 20-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 20-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 20-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 20-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 20-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
+
+twenty_pct = BinomialF(.2, 20, 18)
+thirty_pct = BinomialF(.3, 20, 18)
+fourty_pct = BinomialF(.4, 20, 18)
+fifty_pct = BinomialF(.5, 20, 18)
+sixty_pct = BinomialF(.6, 20, 18)
+seventy_pct = BinomialF(.7, 20, 18)
+eighty_pct = BinomialF(.8, 20, 18)
+ninety_pct = BinomialF(.9, 20, 18)
+
+print "18 out of 20:"
+print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 20-circ groups"
+print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 20-circ groups"
+print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 20-circ groups"
+print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 20-circ groups"
+print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 20-circ groups"
+print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 20-circ groups"
+print "80% circ timeout rate expects "+str(1.0/eighty_pct)+" 20-circ groups"
+print "90% circ timeout rate expects "+str(1.0/ninety_pct)+" 20-circ groups"
+print
diff --git a/CircuitAnalysis/BuildTimes/binomial.py b/CircuitAnalysis/BuildTimes/binomial.py
deleted file mode 100755
index 352f66d..0000000
--- a/CircuitAnalysis/BuildTimes/binomial.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-#
-# Uses the binomial distribution to estimate the expected number of
-# circuit 20-circ groups before a false positive that discards all of our
-# 20-circ groups 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)
-thirty_pct = BinomialF(.35, 20, 15)
-fourty_pct = BinomialF(.4, 20, 15)
-fifty_pct = BinomialF(.5, 20, 15)
-sixty_pct = BinomialF(.6, 20, 15)
-seventy_pct = BinomialF(.7, 20, 15)
-
-print "15 out of 20:"
-print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 20-circ groups"
-print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 20-circ groups"
-print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 20-circ groups"
-print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 20-circ groups"
-print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 20-circ groups"
-print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 20-circ groups"
-print
-
-twenty_pct = BinomialF(.2, 20, 16)
-thirty_pct = BinomialF(.3, 20, 16)
-fourty_pct = BinomialF(.4, 20, 16)
-fifty_pct = BinomialF(.5, 20, 16)
-sixty_pct = BinomialF(.6, 20, 16)
-seventy_pct = BinomialF(.7, 20, 16)
-
-print "16 out of 20:"
-print "20% circ timeout rate expects "+str(1.0/twenty_pct) +" 20-circ groups"
-print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 20-circ groups"
-print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 20-circ groups"
-print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 20-circ groups"
-print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 20-circ groups"
-print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 20-circ groups"
-print
-
-twenty_pct = BinomialF(.2, 20, 18)
-thirty_pct = BinomialF(.30, 20, 18)
-fourty_pct = BinomialF(.40, 20, 18)
-fifty_pct = BinomialF(.5, 20, 18)
-sixty_pct = BinomialF(.6, 20, 18)
-seventy_pct = BinomialF(.7, 20, 18)
-
-print "18 out of 20:"
-print "20% circ timeout rate expects "+str(1.0/twenty_pct)+" 20-circ groups"
-print "30% circ timeout rate expects "+str(1.0/thirty_pct) +" 20-circ groups"
-print "40% circ timeout rate expects "+str(1.0/fourty_pct) +" 20-circ groups"
-print "50% circ timeout rate expects "+str(1.0/fifty_pct)+" 20-circ groups"
-print "60% circ timeout rate expects "+str(1.0/sixty_pct)+" 20-circ groups"
-print "70% circ timeout rate expects "+str(1.0/seventy_pct)+" 20-circ groups"
-print
-- 
1.7.1