utils.knn_density¶
-
utils.
knn_density
(k_radius, n, p, k)¶ Compute the kNN density estimate for a set of points.
Parameters: k_radius : 1-dimensional numpy array of floats
The distance to each points k’th nearest neighbor.
n : int
The number of points.
p : int
The dimension of the data.
k : int
The number of observations considered neighbors of each point.
Returns: fhat : 1D numpy array of floats
Estimated density for the points corresponding to the entries of ‘k_radius’.
See also
Examples
>>> X = numpy.random.rand(100, 2) >>> knn, radii = debacl.utils.knn_graph(X, k=8, method='kd-tree') >>> density = debacl.utils.knn_density(radii, n=100, p=2, k=8)