nn function

Mean distance to kth nearest neighbor