Package Bio :: Package KDTree :: Module KDTree'
[hide private]
[frames] | no frames]

Module KDTree'

source code

KD tree data structure for searching N-dimensional vectors.

The KD tree data structure can be used for all kinds of searches that
involve N-dimensional vectors, e.g.  neighbor searches (find all points
within a radius of a given point) or finding all point pairs in a set
that are within a certain radius of each other. See "Computational Geometry:
Algorithms and Applications" (Mark de Berg, Marc van Kreveld, Mark Overmars,
Otfried Schwarzkopf). Author: Thomas Hamelryck.

Classes [hide private]
  KDTree
KD tree implementation (C++, SWIG python wrapper)
Functions [hide private]
 
_dist(p, q) source code
 
_neighbor_test(nr_points, dim, bucket_size, radius)
Test all fixed radius neighbor search.
source code
 
_test(nr_points, dim, bucket_size, radius)
Test neighbor search.
source code
 
random(size=None)
Return random floats in the half-open interval [0.0, 1.0).
source code
Variables [hide private]
  __package__ = 'Bio.KDTree'
  sqrt = <ufunc 'sqrt'>
Function Details [hide private]

_neighbor_test(nr_points, dim, bucket_size, radius)

source code 
Test all fixed radius neighbor search.

Test all fixed radius neighbor search using the
KD tree C module.

o nr_points - number of points used in test
o dim - dimension of coords
o bucket_size - nr of points per tree node
o radius - radius of search (typically 0.05 or so)

_test(nr_points, dim, bucket_size, radius)

source code 
Test neighbor search.

Test neighbor search using the KD tree C module.

o nr_points - number of points used in test
o dim - dimension of coords
o bucket_size - nr of points per tree node
o radius - radius of search (typically 0.05 or so)

random(size=None)

source code 
Return random floats in the half-open interval [0.0, 1.0).

Results are from the "continuous uniform" distribution over the
stated interval.  To sample :math:`Unif[a, b), b > a` multiply
the output of `random_sample` by `(b-a)` and add `a`::

  (b - a) * random_sample() + a

Parameters
----------
size : int or tuple of ints, optional
    Defines the shape of the returned array of random floats. If None
    (the default), returns a single float.

Returns
-------
out : float or ndarray of floats
    Array of random floats of shape `size` (unless ``size=None``, in which
    case a single float is returned).

Examples
--------
>>> np.random.random_sample()
0.47108547995356098
>>> type(np.random.random_sample())
<type 'float'>
>>> np.random.random_sample((5,))
array([ 0.30220482,  0.86820401,  0.1654503 ,  0.11659149,  0.54323428])

Three-by-two array of random numbers from [-5, 0):

>>> 5 * np.random.random_sample((3, 2)) - 5
array([[-3.99149989, -0.52338984],
       [-2.99091858, -0.79479508],
       [-1.23204345, -1.75224494]])