Example #1
0
def makeStat(seed,
             rate=None,
             minRate=None,
             maxRate=None,
             N=None,
             prior=None,
             cert=None,
             likelihoodObj=None,
             dagObj=None,
             counts=None):

    if rate is None:
        if minRate is None:
            minRate = 0.0
        if maxRate is None:
            maxRate = 1.0
        rate = random.uniform(minRate, maxRate)

    if N is None:
        N = random.randint(2, maxLen)
    if prior is None:
        prior = [1 / float(N) for i in range(N)]

    if cert is None:
        db = random.uniform(3, 6)
        cert = 1.0 - pow(0.5, db)

    if dagObj is None:
        dagObj = dag.listDagObj

    tester = detect(N, rate, dagObj, dagObj is likelihoods.multiRateCalc)
    finder = BBChop.BBChop(prior, cert, tester, likelihoodObj, dagObj)

    loc = tester.loc
    if counts is not None:
        finder.restoreCheckpoint(prior, copy.copy(counts))

    key = (rate, loc, N, cert, counts[-1][0], counts[-1][1],
           likelihoodObj.name().strip(), seed)
    if statDb.has_key(key):
        (tests, guess, right) = statDb.get(key)
        sys.stdout.write('.')
        sys.stdout.flush()

    else:
        guess = finder.search()
        right = (loc == guess)
        tests = tester.tests
        sys.stdout.write('#')
        sys.stdout.flush()
        statDb.add(key, (tests, guess, right))

    return (rate, loc, N, cert, tests, guess, right, likelihoodObj.name(),
            counts[-1])
Example #2
0
def mergeStats(fileName):
    f=file(fileName,"r")
    
    for line in f:
        line=line.replace('(','')
        line=line.replace(')','')
        line=line.replace("'",'')
        
        (rate,loc,N,cert,tests,guess,right,lname,lastCountT,lastCountD,seed)=line.split(',')
        

        key=(float(rate),int(loc),int(N),float(cert),int(lastCountT),int(lastCountD),lname.strip(),int(seed))
        result=(float(tests),int(guess),right.strip()=='True')
        statDb.add(key,result)
    f.close()
Example #3
0
def makeStat(seed,rate=None,minRate=None,maxRate=None,N=None,prior=None,cert=None,likelihoodObj=None,dagObj=None,counts=None):
    

    if rate is None:
        if minRate is None:
            minRate=0.0
        if maxRate is None:
            maxRate=1.0
        rate=random.uniform(minRate,maxRate)

    if N is None:
        N=random.randint(2,maxLen)
    if prior is None:
        prior=[ 1/float(N) for i in range(N)]

    if cert is None:
        db=random.uniform(3,6)
        cert=1.0-pow(0.5,db)

    if dagObj is None:
        dagObj=dag.listDagObj


    tester=detect(N,rate,dagObj,dagObj is likelihoods.multiRateCalc)
    finder=BBChop.BBChop(prior,cert,tester,likelihoodObj,dagObj)
    
    loc=tester.loc
    if counts is not None:
        finder.restoreCheckpoint(prior,copy.copy(counts))
    
    key=(rate,loc,N,cert,counts[-1][0],counts[-1][1],likelihoodObj.name().strip(),seed)
    if statDb.has_key(key):
        (tests,guess,right)=statDb.get(key)
        sys.stdout.write('.')
        sys.stdout.flush()
        
    else:
        guess=finder.search()
        right=(loc==guess)
        tests=tester.tests
        sys.stdout.write('#')
        sys.stdout.flush()
        statDb.add(key,(tests,guess,right))


    return (rate,loc,N,cert,tests,guess,right,likelihoodObj.name(),counts[-1])