[or-cvs] r15926: There we go. Finally. (torflow/branches/gsoc2008/tools/BTAnalysis)

mikeperry at seul.org mikeperry at seul.org
Tue Jul 15 07:22:29 UTC 2008


Author: mikeperry
Date: 2008-07-15 03:22:29 -0400 (Tue, 15 Jul 2008)
New Revision: 15926

Modified:
   torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py
Log:

There we go. Finally.



Modified: torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py
===================================================================
--- torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py	2008-07-15 07:20:55 UTC (rev 15925)
+++ torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py	2008-07-15 07:22:29 UTC (rev 15926)
@@ -1,3 +1,4 @@
+#!/usr/bin/python
 import numpy
 import pylab
 import matplotlib
@@ -4,7 +5,7 @@
 
 
 def loadbuildtimes():
-  f = open('buildtimes')
+  f = open('40k_r1/45-50.40000.buildtimes')
   vals = []
   for line in f:
     line = line.split('\t')
@@ -15,7 +16,7 @@
 
     
 def pareto(x,k,Xm):
-  return k * (Xm**k)/(x**(k+1))
+  return k*(Xm**k)/(x**(k+1))
 
 #get buildtime data (in ms)
 Z = loadbuildtimes()
@@ -23,7 +24,7 @@
 # plot histogram.
 # args: values, number of bins, normalize y/n, width of bars
 
-#pylab.hist(Z,len(Z) / 100.0, normed=False, width=5)
+pylab.hist(Z,len(Z) / 100.0, normed=True, width=5)
 
 #pareto parameters (taken from output of ./shufflebt.py buildtimes)
 #Resolution of histogram: 100 ms
@@ -32,17 +33,26 @@
 #ModeN: 32775 vs integrated: 32394.9483089
 #successful runs: 41712
 
-k = 0.918058347945 
-Xm = 1600
-n = 32775
+k = 0.687880881456 
+Xm = 1800
+n = 28921
 
+
 # args to a range: x start, x end 
-X = pylab.arange(1,max(Z),0.1)            # x values from  1 to max(Z) in increments of 0.1 (can adjust this to look at different parts of the graph)
-Y = map(lambda x: n *pareto(x,k,Xm), X) #pareto(x) (units: #measurements with value x)
+X = pylab.arange(Xm, max(Z), 1) # max(Z), 0.1)    # x values from  1 to max(Z) in increments of 0.1 (can adjust this to look at different parts of the graph)
+Y = map(lambda x: pareto(x,k,Xm), X) #pareto(x) (units: #measurements with value x)
 
+# verify sanity by integrating scaled distribution:
+modeNint = numpy.trapz(map(lambda x: n*pareto(x, k, Xm),
+                 xrange(Xm,200000)))
+
+print modeNint
+
+print n*pareto(Xm, k, Xm)
+
 #draw pareto curve
 # X values plotted against Y values, will appear as blue circles b:blue o:circle
-pylab.plot(X,Y,'bo')
+pylab.plot(X,Y,'b-')
 
 #save figure
 pylab.savefig('paretofig.png')



More information about the tor-commits mailing list