def meanInClusterDistances(cluster): overlaps = [] perms = list(permutations(cluster, 2)) for (sdr1, sdr2) in perms: overlap = percentOverlap(sdr1, sdr2) overlaps.append(overlap) return sum(overlaps) / len(overlaps)
def computeDistanceMat(sdrs): """ Compute distance matrix between SDRs :param sdrs: (array of arrays) array of SDRs :return: distance matrix """ numSDRs = len(sdrs) # calculate pairwise distance distanceMat = np.zeros((numSDRs, numSDRs), dtype=np.float64) for i in range(numSDRs): for j in range(numSDRs): distanceMat[i, j] = 1 - percentOverlap(sdrs[i], sdrs[j]) return distanceMat