scipy.spatial.KDTree.count_neighbors¶
- KDTree.count_neighbors(other, r, p=2.0)[source]¶
- Count how many nearby pairs can be formed. - Count the number of pairs (x1,x2) can be formed, with x1 drawn from self and x2 drawn from other, and where distance(x1, x2, p) <= r. This is the “two-point correlation” described in Gray and Moore 2000, “N-body problems in statistical learning”, and the code here is based on their algorithm. - Parameters: - other : KDTree instance - The other tree to draw points from. - r : float or one-dimensional array of floats - The radius to produce a count for. Multiple radii are searched with a single tree traversal. - p : float, 1<=p<=infinity, optional - Which Minkowski p-norm to use - Returns: - result : int or 1-D array of ints - The number of pairs. Note that this is internally stored in a numpy int, and so may overflow if very large (2e9). 
