Warning
This documentation is workinprogress and unorganized.
Nearestneighbor queries:
KDTree – class for efficient nearestneighbor queries distance – module containing many different distance measures
kdtree for quick nearestneighbor lookup
This class provides an index into a set of kdimensional points which can be used to rapidly look up the nearest neighbors of any point.
The algorithm used is described in Maneewongvatana and Mount 1999. The general idea is that the kdtree is a binary trie, each of whose nodes represents an axisaligned hyperrectangle. Each node specifies an axis and splits the set of points based on whether their coordinate along that axis is greater than or less than a particular value.
During construction, the axis and splitting point are chosen by the “sliding midpoint” rule, which ensures that the cells do not all become long and thin.
The tree can be queried for the r closest neighbors of any given point (optionally returning only those within some maximum distance of the point). It can also be queried, with a substantial gain in efficiency, for the r approximate closest neighbors.
For large dimensions (20 is already large) do not expect this to run significantly faster than brute force. Highdimensional nearestneighbor queries are a substantial open problem in computer science.
The tree also supports allneighbors queries, both with arrays of points and with other kdtrees. These do use a reasonably efficient algorithm, but the kdtree is not necessarily the best data structure for this sort of calculation.
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 “twopoint correlation” described in Gray and Moore 2000, “Nbody problems in statistical learning”, and the code here is based on their algorithm.
Parameters:  other : KDTree r : float or onedimensional array of floats
p : float, 1<=p<=infinity


Returns:  result : integer or onedimensional array of integers

Find all points within r of x
Parameters:  x : array_like, shape tuple + (self.m,)
r : positive float
p : float 1<=p<=infinity
eps : nonnegative float


Returns:  results : list or array of lists
Note: if you have many points whose neighbors you want to find, you may save : substantial amounts of time by putting them in a KDTree and using query_ball_tree. : 
Find all pairs of points whose distance is at most r
Parameters:  other : KDTree
r : positive float
p : float 1<=p<=infinity
eps : nonnegative float


Returns:  results : list of lists

Compute a sparse distance matrix
Computes a distance matrix between two KDTrees, leaving as zero any distance greater than max_distance.
Parameters:  other : KDTree max_distance : positive float 

Returns:  result : dok_matrix

Hyperrectangle class.
Represents a Cartesian product of intervals.
Produce two hyperrectangles by splitting along axis d.
In general, if you need to compute maximum and minimum distances to the children, it can be done more efficiently by updating the maximum and minimum distances to the parent.
kdtree for quick nearestneighbor lookup
This class provides an index into a set of kdimensional points which can be used to rapidly look up the nearest neighbors of any point.
The algorithm used is described in Maneewongvatana and Mount 1999. The general idea is that the kdtree is a binary trie, each of whose nodes represents an axisaligned hyperrectangle. Each node specifies an axis and splits the set of points based on whether their coordinate along that axis is greater than or less than a particular value.
During construction, the axis and splitting point are chosen by the “sliding midpoint” rule, which ensures that the cells do not all become long and thin.
The tree can be queried for the r closest neighbors of any given point (optionally returning only those within some maximum distance of the point). It can also be queried, with a substantial gain in efficiency, for the r approximate closest neighbors.
For large dimensions (20 is already large) do not expect this to run significantly faster than brute force. Highdimensional nearestneighbor queries are a substantial open problem in computer science.
Compute the distance matrix.
Computes the matrix of all pairwise distances.
Parameters:  x : arraylike, m by k y : arraylike, n by k p : float 1<=p<=infinity
threshold : positive integer


Returns:  result : arraylike, m by n 
Compute the pth power of the L**p distance between x and y
For efficiency, this function computes the L**p distance but does not extract the pth root. If p is 1 or infinity, this is equal to the actual L**p distance.