Exemplo n.º 1
0
def calculateAllPairDistance(options):
    numberOfData = options['numberOfData']
    dim          = options['numberOfDimension']
    numberOfVP   = options['numberOfVP']
    cardinality  = options['numberOfAlphabet']
    typeOfVP     = options['typeOfVP']
    vps = utils.readDataFromFile(utils.getVPFileName(options))
    for i in xrange(len(vps)):
        for j in xrange(i+1,len(vps)):
            print i,j,utils.hammingDistance(vps[i],vps[j])
Exemplo n.º 2
0
def calculateAllPairDistance(options):
    numberOfData = options['numberOfData']
    dim = options['numberOfDimension']
    numberOfVP = options['numberOfVP']
    cardinality = options['numberOfAlphabet']
    typeOfVP = options['typeOfVP']
    vps = utils.readDataFromFile(utils.getVPFileName(options))
    d = [0 for i in xrange(dim + 1)]
    s = set()
    for i in xrange(len(vps)):
        for j in xrange(i + 1, len(vps)):
            dist = utils.hammingDistance(vps[i], vps[j])
            d[dist] = d[dist] + 1
            s.add(dist)
            print i, j, dist
    for i in xrange(0, dim + 1):
        print i, d[i]
    print len(s)
Exemplo n.º 3
0
        self.x = x
        self.id1 = id1
        self.id2 = id2
    def __lt__(self,other):
        if self.x == other.x:
            return self.id1 < self.id2
        return self.x < other.x

if __name__ == '__main__':
    options = utils.getOptions()
    dataFileName = 'data/data_%d_%d_%s_%d.txt'%(options['numberOfData'],options['numberOfDimension'],options['distribution'],options['numberOfAlphabet'])
    
    print dataFileName
    datas = utils.getDataInFile(dataFileName)

    filename = utils.getVPFileName(options)
    print filename
    with open(filename,'r') as fp:
        lines = fp.read().rstrip().split('\n')
    vps = []
    for line in lines:
        vps.append(line.rstrip().split(' '))
    cc = []
    for i in xrange(len(vps)):
        for j in xrange(len(vps)):
            if i == j:
                continue
            cc.append(CC(abs(utils.calculateCorrelationCoefficient(vps[i],vps[j],datas)),i,j))
    cc.sort()
    for i in xrange(min(4,len(cc))):
        cur = -(i+1)