'The local reachability density (LRD)
The LRD of a sample is the inverse of the average reachability
distance of its k-nearest neighbors.
Parameters
distances_X : array, shape (n_query, self.n_neighbors)
Distances to the neighbors (in the training samples `self._fit_X`)
of each query point to compute the LRD.
neighbors_indices : array, shape (n_query, self.n_neighbors)
Neighbors indices (of each query point) among training samples
self._fit_X.
Returns
local_reachability_density : array, shape (n_samples,)
The local reachability density of each sample.'

def _local_reachability_density(self, distances_X, neighbors_indices):

    dist_k = self._distances_fit_X_[(neighbors_indices, (self.n_neighbors_ - 1))]
    reach_dist_array = np.maximum(distances_X, dist_k)
    return (1.0 / (np.mean(reach_dist_array, axis=1) + 1e-10))
