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

[or-cvs] r15298: Tinker a little with these distributions. Add a FIXME to try (torflow/branches/gsoc2008/tools/BTAnalysis)



Author: mikeperry
Date: 2008-06-15 23:05:32 -0400 (Sun, 15 Jun 2008)
New Revision: 15298

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

Tinker a little with these distributions. Add a FIXME to try
out a gamma distribution, which looks promising.



Modified: torflow/branches/gsoc2008/tools/BTAnalysis/shufflebt.py
===================================================================
--- torflow/branches/gsoc2008/tools/BTAnalysis/shufflebt.py	2008-06-16 02:25:49 UTC (rev 15297)
+++ torflow/branches/gsoc2008/tools/BTAnalysis/shufflebt.py	2008-06-16 03:05:32 UTC (rev 15298)
@@ -80,10 +80,16 @@
 
 def poisson(u,N,fname):
   ps = fname + "(x) = " + str(N) + "*(" + str(u) + "**x)*exp(-"+str(u)+")/gamma(x + 1)\n"
-  return ps 
+  return ps
+
+def normal(u,d,N,fname):
+  ps = fname + "(x)="+str(int(N)/d)+"*(exp(-((x-"+str(u)+ ")**2)/"+str(2*d*d)+"))/sqrt(2*pi)\n"
+  return ps
+
 def usage():
   print "shufflebt.py -n <# circuits> -f <timefile> -d <outdirname>"
 
+
 def setargs():
   ncircuits = ""
   dirname = ""
@@ -145,15 +151,29 @@
   plotname =  newfile + '.plt'
   plotstr = "set terminal png transparent nocrop enhanced size 800,600\nset output '" + newfile + ".png'\nset style fill  solid 1.00 border -1\nset style histogram clustered gap 1 title  offset character 0, 0, 0\nset datafile missing '-'\nset style data histograms\nset title 'Buildtime Distribution Function for "+ ncircuits +" Circuits'\nset ylabel '# Circuits'\nset xlabel 'time (in 100ms)'\n"
   plotstr += "set label 'std dev=" + str(stddev) + "' at 450,1380\n"
-  plotstr += poisson(mean,ncircuits,'pmean')
-  plotstr += poisson(median,ncircuits,'pmedian')
-  plotstr += poisson(mode,ncircuits,'pmode')
+
+  # FIXME: Hrmm... http://en.wikipedia.org/wiki/Skewness? Seems like a hack
+  # Or better: http://en.wikipedia.org/wiki/Gamma_distribution with k=3?
+  # Would make sense if this is the sum of 3 paretos for the individual
+  # hop distributions.
+  plotstr += poisson(mean*10,ncircuits,'pmean')
+  plotstr += poisson(median*10,ncircuits,'pmedian')
+  plotstr += poisson(mode*10,ncircuits,'pmode')
+  plotstr += normal(mean*10,stddev*10,ncircuits,'nmean')
+  plotstr += normal(median*10,stddev*10,ncircuits,'nmedian')
+  plotstr += normal(mode*10,stddev*10,ncircuits,'nmode')
+
   plotstr += "plot '" + newfile + ".hist' using 2,\\\n"
 
+  plotstr += "nmean(x) title '" + "mean=" + str(mean) + "' ,\\\n"
+  plotstr += "nmedian(x) title '" + "median=" + str(median) + "' ,\\\n"
+  plotstr += "nmode(x) title '" + "mode=" + str(mode) + "' ,\\\n"
+
   plotstr += "pmean(x) title '" + "mean=" + str(mean) + "' ,\\\n"
   plotstr += "pmedian(x) title '" + "median=" + str(median) + "' ,\\\n"
   plotstr += "pmode(x) title '" + "mode=" + str(mode) + "' \\\n"
 
+
   f = open(plotname,'w')
   f.write(plotstr)
   f.close()