I am currently trying to make a nearest neighbour (NN) analysis in Python where I test if points in a spatial distribution are clustering (or forming subclusters). I have a distribution of points in an area, and each point belongs to a specific group (group 0-13). I am testing if the NN of each point belongs to the same group or another group, but I would also like to add some aspect of probability to it, i.e., in a complete spatial random distribution, how likely is it that group x has this many NN also in group x. How would I go around doing that? I am succesfully identifying whether the NN of a point belongs to the same group, and giving the group a score (+1 for each NN in the same group, -1 for each not in the group) Continue reading...