Ejemplo n.º 1
0
def testEntropyFunc(entropyFunc1,entropyFunc2,likelihoodArg1,likelihoodArg2,falsePos=False,falseNeg=False,maxCount=10,randomDag=False):
    print "testing " ,entropyFunc1.func_name,entropyFunc2.func_name,likelihoodArg1.name(),likelihoodArg2.name(),"maxCount=",maxCount,"randomDag=",randomDag
    
    fail=False
    for t in  range(tests):

        d=testCases.testDag(n,randomDag)
        (counts,locPrior)=testCases.randomEntropyData(t+1,n,d,falsePos,falseNeg,maxCount)
        
    
#        pdb.set_trace()
        (c1,e1,f1)=entropyFunc1(counts,locPrior,likelihoodArg1,d)
    #    pdb.set_trace()
        (c2,e2,f2)=entropyFunc2(counts,locPrior,likelihoodArg2,d)
    
        thisFail=False
        if not rough_eq(c1,c2):
            print "Error:\t",c1,c2
            thisFail=True
            
        for j in range(n):
    #        print "entropy:\t ",j,e1[j],e2[j] #,max(e1[j]/e2[j],e2[j]/e1[j])
            if not rough_eq(e1[j],e2[j]):
                print "Error:\t",e1[j],e2[j]
                thisFail=True
    
        if thisFail:
            fail=True
            print "test %d failed!" % t
        else:
            print "test %d passed" % t
    if fail:
        print "FAILED!"
    else:
        print "PASSED!"

    return fail
Ejemplo n.º 2
0
import testCases


random.seed(1)



mult=100

out=file("data/N_T.singleRate.csv","w")
for n in range(50,1000,50):





    d=testCases.testDag(n,False)


    for i in range(mult):
        (counts,locPrior)=testCases.randomEntropyData(i+1,n,d,False,True,10)
        start=time.clock()
        junk=evidence.entropiesFast(counts,locPrior,likelihoods.singleRateCalc,d)
        end=time.clock()
        out.write("%d,%f\n" % (n,(end-start)))
    print n

out.close()
                  

Ejemplo n.º 3
0
#
#    You should have received a copy of the GNU General Public License
#    along with BBChop.  If not, see <http://www.gnu.org/licenses/>.

import evidence
import time
import random
import likelihoods
import testCases

random.seed(1)

mult = 100

out = file("data/N_T.singleRate.csv", "w")
for n in range(50, 1000, 50):

    d = testCases.testDag(n, False)

    for i in range(mult):
        (counts,
         locPrior) = testCases.randomEntropyData(i + 1, n, d, False, True, 10)
        start = time.clock()
        junk = evidence.entropiesFast(counts, locPrior,
                                      likelihoods.singleRateCalc, d)
        end = time.clock()
        out.write("%d,%f\n" % (n, (end - start)))
    print n

out.close()