K-d tree: Difference between revisions
Content added Content deleted
Line 1,313: | Line 1,313: | ||
const kdtree = KDTree(Float64.(data)) |
const kdtree = KDTree(Float64.(data)) |
||
const indexpoint = [9,2] |
const indexpoint = [9,2] |
||
idx, dist = knn(kdtree, indexpoint, 1) |
|||
println("Wikipedia example: The nearest neighbor to $indexpoint is ", |
println("Wikipedia example: The nearest neighbor to $indexpoint is ", |
||
"$(data[1:2, |
"$(data[1:2, idx[1]]) at distance $(dist).") |
||
NearestNeighbors.print_stats() |
NearestNeighbors.print_stats() |
||
Line 1,322: | Line 1,322: | ||
const kdcubetree = KDTree(cubedis) |
const kdcubetree = KDTree(cubedis) |
||
const rand3point = rand(3, 1) |
const rand3point = rand(3, 1) |
||
idx, dist = knn(kdcubetree, rand3point, 1) |
|||
println("\n\ |
println("\n\n1000 cube points: The point $rand3point is closest to the point $(cubedis[1:3, idx[1]])", |
||
" at distance $( |
" at distance $(dist[1]).") |
||
NearestNeighbors.print_stats() |
NearestNeighbors.print_stats() |
||
Line 1,331: | Line 1,331: | ||
NearestNeighbors.reset_stats() |
NearestNeighbors.reset_stats() |
||
const cubedis2 = rand(3, 500000) |
const cubedis2 = rand(3, 500000) |
||
const kdcubetree2 = KDTree( |
const kdcubetree2 = KDTree(cubedis2) |
||
const rand3point2 = rand(3, 1) |
const rand3point2 = rand(3, 1) |
||
idx, dist = knn(kdcubetree2, rand3point2, 1) |
|||
println("\n\ |
println("\n\nExtra: The point $rand3point2 is closest to the point $(cubedis2[1:3, idx[1]]) out of $(size(cubedis2)[2]) points,", |
||
" at distance $( |
" at distance $(dist[1]).") |
||
NearestNeighbors.print_stats() |
NearestNeighbors.print_stats() |
||
</lang> |
</lang> |
||
Line 1,346: | Line 1,346: | ||
The point [0. |
1000 cube points: The point [0.386894; 0.465532; 0.710547] is closest to the point [0.389152; 0.459995; 0.639123] at distance [0.0716743]. |
||
Nodes visited: |
Nodes visited: 13 |
||
Points visited: 30, out of these: 0 unchecked. |
Points visited: 30, out of these: 0 unchecked. |
||
The point [0. |
Extra: The point [0.373496; 0.740711; 0.417431] is closest to the point [0.377841; 0.744084; 0.420237] out of 500000 points, at distance [0.00617466]. |
||
Nodes visited: |
Nodes visited: 28 |
||
Points visited: |
Points visited: 40, out of these: 0 unchecked. |
||
</pre> |
</pre> |
||