megicparc.functions.compute_density

megicparc.functions.compute_density(sort_dist_vals, k_nn)
Compute density function

pho(i) = 1/sum_{j in N(i)} d_ij, i = 1, …, n

Parameters

sort_dist_valsndarray of float, shape (n_sources, n_sources-1)

Distance matrix, each row sorted in ascending order.

k_nnint in (0, +inf]

Number of nearest neighbours

Returns

densityarray of float, shape (n_sources, )

Density function

nncountsarray of int, shape (n_sources, )

Actual size of the sets of nearest neighbours