KristofferC / NearestNeighbors.jl

High performance nearest neighbor data structures (KDTree and BallTree) and algorithms for Julia.
Other
413 stars 65 forks source link

Document that `inrangecount` also counts the point itself #153

Closed kahaaga closed 2 years ago

kahaaga commented 2 years ago

I can use inrangecount(tree, point, r) to count the number of points within radius r from point. It was unclear to me from the documentation whether point itself was included in this count or not. However, from the following example, it seems that it is. Perhaps this should be documented?

julia> using DelayEmbeddings, NearestNeighbors
julia> x = repeat([0.1], 10) .+ rand(10) * 0.001;
julia> pts = genembed(x, 0:2);
julia> tree = KDTree(pts.data, Chebyshev());
julia> r = 0.0
julia> inrangecount(tree, pts[1], r)
1
KristofferC commented 2 years ago

It doesn't really count the point itself because the point given does not necessarily exist in the tree. From the algorithms p.o.v is it more an "accident" that the input point happens to coincide with a point in the tree.

kahaaga commented 2 years ago

It doesn't really count the point itself because the point given does not necessarily exist in the tree. From the algorithms p.o.v is it more an "accident" that the input point happens to coincide with a point in the tree.

Thanks for the clarification! I guess the distinction first becomes relevant in my particular use case, where I query points that also exist in the tree.