K-d tree: Difference between revisions

m
Line 1,325:
 
println("\n\nThe point $rand3point is closest to the point $(cubedis[1:3, idxs[1]])",
" at distance $(dists[1]).")
NearestNeighbors.print_stats()
 
 
NearestNeighbors.reset_stats()
const cubedis2 = rand(3, 100000)
const kdcubetree2 = KDTree(cubedis)
const rand3point2 = rand(3, 1)
idxs, dists = knn(kdcubetree2, rand3point2, 1)
 
println("\n\nThe point $rand3point2 is closest to the point $(cubedis2[1:3, idxs[1]]) out of $(size(cubedis2)[2]) points, ",
" at distance $(dists[1]).")
NearestNeighbors.print_stats()
</lang>
{{out}}
Wikipedia example: The nearest neighbor to [9, 2] is [8, 1] at distance [1.41421].
Nodes visited: 1
Points visited: 6, out of these: 0 unchecked.
 
 
The point [0.479231225306; 0.3033626753; 0.979979866174] is closest to the point [0.531064234483; 0.349748214272; 0.943587903621] at distance [0.0785038065749].
Nodes visited: 816
Points visited: 1060, out of these: 0 unchecked.
 
 
The point [0.845167; 0.636466; 0.196453] is closest to the point [0.947299; 0.204084; 0.266638] out of 100000 points, at distance [0.0613915].
Nodes visited: 12
Points visited: 40, out of these: 0 unchecked.
</pre>
 
4,105

edits