added function to compute information from nearest neighbors in python