def compare(self, scc): # Return a score between 0.0 (most dissimilar) and 1.0 (most similar) # For normalized histograms, the maximum chiSq distance = 1.0, minimum 0.0 dist = stats.chiSquaredHistogramDistance(self._vec, scc._vec) res = 1.0 - dist return res
def testknown(self): """Histogram distance, known""" a = [1,3] b = [3,1] d = stats.chiSquaredHistogramDistance(a,b) self.assertAlmostEqual(d,1.0)
def testuneq(self): """Histogram distance, equal""" a = [1,3,5,2,4,0,7,7.01] b = [1,3,5,2,4,0,7,7.01] d = stats.chiSquaredHistogramDistance(a,b) self.assertAlmostEqual(d, 0.0)
def testeq(self): """Histogram distance, unequal""" a = [1,3,5,2,4,0,7,7.01] b = [1,3,5,2,4,0,7,8] d = stats.chiSquaredHistogramDistance(a,b) self.assertTrue(d>0.0)