Similarity measurement based on Gaussian Distribution

def _high_dim_sim(self, v, w, normalize=False, X=None, idx=0):
        """Similarity measurement based on Gaussian Distribution"""

        sim = np.exp((-np.linalg.norm(v - w) ** 2) / (2*self._sigma[idx] ** 2))

        if normalize:
            return sim / sum(map(lambda x: x[1], self._knn(idx, X, high_dim=True)))
        else:
            return sim