[or-cvs] r15918: Simplified numpy script for inspecting fit with Pareto distr (torflow/branches/gsoc2008/tools/BTAnalysis)

fallon at seul.org fallon at seul.org
Tue Jul 15 04:42:46 UTC 2008


Author: fallon
Date: 2008-07-15 00:42:45 -0400 (Tue, 15 Jul 2008)
New Revision: 15918

Added:
   torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py
Log:
Simplified numpy script for inspecting fit with Pareto distribution. Run with the command python numpy_pareto.py -dAgg if you're doing this remotely.


Added: torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py
===================================================================
--- torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py	                        (rev 0)
+++ torflow/branches/gsoc2008/tools/BTAnalysis/numpy_pareto.py	2008-07-15 04:42:45 UTC (rev 15918)
@@ -0,0 +1,49 @@
+import numpy
+import pylab
+import matplotlib
+
+
+def loadbuildtimes():
+  f = open('buildtimes')
+  vals = []
+  for line in f:
+    line = line.split('\t')
+    vals += [float(line[1].strip())*1000]
+  vals.sort()
+  vals.reverse()
+  return vals
+
+    
+def pareto(x,k,Xm):
+  return k * (Xm**k)/(x**(k+1))
+
+#get buildtime data (in ms)
+Z = loadbuildtimes()
+
+# plot histogram.
+# args: values, number of bins, normalize y/n, width of bars
+
+#pylab.hist(Z,len(Z) / 100.0, normed=False, width=5)
+
+#pareto parameters (taken from output of ./shufflebt.py buildtimes)
+#Resolution of histogram: 100 ms
+#Mean: 5746.8020777, mode: 1600
+#ParK: 0.918058347945
+#ModeN: 32775 vs integrated: 32394.9483089
+#successful runs: 41712
+
+k = 0.918058347945 
+Xm = 1600
+n = 32775
+
+# 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)
+
+#draw pareto curve
+# X values plotted against Y values, will appear as blue circles b:blue o:circle
+pylab.plot(X,Y,'bo')
+
+#save figure
+pylab.savefig('paretofig.png')
+



More information about the tor-commits mailing list