function compute_means_and_weights_with_distances(points, centers, Σ )
d, c = size(centers)
μ, ω = zeros(d, c), zeros(c)
Threads.@threads for i in eachindex(ω)
dist = SqMahalanobis(Σ[i])
dists = pairwise(dist, data.points, centers[:,[i]], dims=2 )
idxs = sortperm(vec(dists))[1:k]
μ[:,i] .= vec(mean(view(points, :, idxs), dims = 2))
ω[i] = mean(pairwise(dist, view(points,:, idxs), μ[:,[i]], dims=2))
end
return μ, ω
end
compute_means_and_weights_with_distances (generic function with 1 method)