[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[freehaven-cvs] gather percentiles of num-rounds-to-guess-N
Update of /home/freehaven/cvsroot/doc/e2e-traffic/src
In directory moria.mit.edu:/tmp/cvs-serv16122
Modified Files:
analyze.py
Log Message:
gather percentiles of num-rounds-to-guess-N
Index: analyze.py
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/analyze.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- analyze.py 19 Jan 2004 01:00:13 -0000 1.3
+++ analyze.py 20 Jan 2004 02:20:32 -0000 1.4
@@ -1,6 +1,7 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.3
import gzip
+import math
import sys
import time
@@ -74,6 +75,40 @@
def pct(x):
return int(x*100)
+class RecipientDistribution:
+ def __init__(self, M):
+ self.M=M
+ self.items = 0
+ self.lst = [[], #1/2,
+ [], #3/4
+ [], #7/8
+ [], #15/16
+ [], #all-but-1
+ [], #all.
+ ]
+ self.positions = [ (0, M//2),
+ (1, (M*3)//4),
+ (2, (M*7)//8),
+ (3, (M*15)//16),
+ (4, M-1),
+ (5, M) ]
+ def addResult(self,res):
+ got=len(res)-1
+ self.items += 1
+ for idx, pos in self.positions:
+ if got>=pos:
+ self.lst[idx].append(res[pos])
+ def getPercentile(self,pctile):
+ r = []
+ p = int(math.ceil(self.items * (pctile/100.0)))
+ for l in self.lst:
+ l.sort()
+ if p < len(l):
+ r.append(l[p])
+ else:
+ r.append(None)
+ return r
+
class ResultSet:
SCOPE = { 'MixTrial' : MixTrialParams,
'UnkBGBatchTrial' : UnkBGParams,
@@ -85,6 +120,7 @@
self.nRounds = {}
self.nRoundsAlice = {}
self.nGuessed = {}
+ self.nRoundsToGuessN = {}
def readFile(self,fn):
f = gzopen(fn)
@@ -97,6 +133,7 @@
nRounds = self.nRounds
nRoundsAlice = self.nRoundsAlice
nGuessed = self.nGuessed
+ nRoundsToGuessN = self.nRoundsToGuessN
xth = 0
try:
while 1:
@@ -122,12 +159,14 @@
nRounds[params]=0
nRoundsAlice[params]=0
nGuessed[params]=0
+ nRoundsToGuessN[params] = \
+ RecipientDistribution(params.getM())
if result['succeeded']:
nSuccess[params] += 1
nRounds[params] += result['rounds']
nRoundsAlice[params] += result['roundsWithAlice']
nGuessed[params] += len(result['nRoundsToGuessNth'])-1
-
+ nRoundsToGuessN[params].addResult(result['nRoundsToGuessNth'])
#i += 1
#if not (i % 100):
# print i, (time.time()-start)/i
@@ -153,8 +192,10 @@
pG = self.nGuessed[p]/(fT*p.getM())
dp = p.disp()
- print ("%s | N:%3d succ:%3s%% guess:%3s%% rnds:%7d rndsA:%7d"
- %(dp, nT, int(pS*100), int(pG*100), avgR, avgRA))
+ nrtgn = self.nRoundsToGuessN[p]
+
+ print ("%s | N:%3d succ:%3s%% guess:%3s%% rnds:%7d rndsA:%7d mmR:%7s"
+ %(dp, nT, int(pS*100), int(pG*100), avgR, avgRA, medmed))
if __name__ == '__main__':
rs = ResultSet()
***********************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe freehaven-cvs in the body. http://freehaven.net/