K-d tree: Difference between revisions

Line 1,313:
const kdtree = KDTree(Float64.(data))
const indexpoint = [9,2]
idxsidx, distsdist = knn(kdtree, indexpoint, 1)
println("Wikipedia example: The nearest neighbor to $indexpoint is ",
"$(data[1:2, idxsidx[1]]) at distance $(distsdist).")
NearestNeighbors.print_stats()
 
Line 1,322:
const kdcubetree = KDTree(cubedis)
const rand3point = rand(3, 1)
idxsidx, distsdist = knn(kdcubetree, rand3point, 1)
 
println("\n\nThen1000 cube points: The point $rand3point is closest to the point $(cubedis[1:3, idxsidx[1]])",
" at distance $(distsdist[1]).")
NearestNeighbors.print_stats()
 
Line 1,331:
NearestNeighbors.reset_stats()
const cubedis2 = rand(3, 500000)
const kdcubetree2 = KDTree(cubediscubedis2)
const rand3point2 = rand(3, 1)
idxsidx, distsdist = knn(kdcubetree2, rand3point2, 1)
 
println("\n\nThenExtra: The point $rand3point2 is closest to the point $(cubedis2[1:3, idxsidx[1]]) out of $(size(cubedis2)[2]) points, ",
" at distance $(distsdist[1]).")
NearestNeighbors.print_stats()
</lang>
Line 1,346:
 
 
1000 cube points: The point [0.857886386894; 0.503096465532; 0.0873481710547] is closest to the point [0.885883389152; 0.475486459995; 0.0320433639123] at distance [0.06785890716743].
Nodes visited: 1413
Points visited: 30, out of these: 0 unchecked.
 
 
Extra: The point [0.535338373496; 0.546231740711; 0.984988417431] is closest to the point [0.430079377841; 0.848971744084; 0.689986420237] out of 500000 points, at distance [0.060889900617466].
Nodes visited: 2128
Points visited: 5040, out of these: 0 unchecked.
</pre>
 
4,105

edits