Skip to content

Commit

Permalink
core_distances() tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst authored Apr 27, 2024
1 parent 380acf1 commit 6fdebe6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/hdbscan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ function hdbscan(points::AbstractMatrix, k::Int, min_cluster_size::Int; metric=E
return HdbscanResult(result, assignments)
end

# calculate the core distances of the points
# calculate the core (k-th nearest) distances of the points
function core_distances(dists::AbstractMatrix, k::Integer)
core_dists = Array{Float64}(undef, size(dists, 1))
for i in axes(dists, 1)
dist = sort(dists[i, :])
core_dists[i] = dist[k]
for i in axes(dists, 2)
core_dists[i] = partialsort!(dists[:, i], k)
end
return core_dists
end
Expand Down

0 comments on commit 6fdebe6

Please sign in to comment.