Previously, I asked the question how to calculate the expected distance to the nearest neighbor molecule in 3-dimensional space. This question was fully answered, which is I ask this related question in a separate thread. As a disclaimer, I know that the previous answer reflects the literature, and I do not intend to question its validity whatsoever.

I wanted to calculate the expected distance of 1 particular of 500 molecules to its closet of 499 neighbors that are randomly diffusing in a volume of 1 cubic micrometer.

I think I understand the following statement:

Since the neighbor positions are independent, the chance that all are further than distance 𝑟 is

$$ S_{N;d}(r) = (1-r^d)^N. $$

But to my mind, without former education in math and statistics, I would argue that the derivative of this function - the change in probability at given r - should reflect the probability of finding closest neighbors at this r. Also this approach seemingly perfectly recreates a 3d simulation:

3D simulation (Python)

import numpy as np

import numpy as np
def min_eucledian(centers):
    squared = np.square(centers)
    summed = [sum(squared[i*3:i*3+3]) for i in range(len(squared)//3)]
    return np.sqrt(min(summed))

N = 499
simulation_length = 3*10**6 #this was used, I know it is excessive
distances = []
for i in range(simulation_length):
    protein_centers = np.random.uniform(low=-500, high=500, size=N*3)
    if i%10000 == 0:

enter image description here

enter image description here

"Derivative" approach

Probability of finding 0 neighbors within r:

enter image description here


enter image description here

So, the derivative seems logical to me, also it perfectly recreates the simulation. Instead, the textbook approach is off by around 70%. (see linked question)

So I would like to ask 2 questions:

  1. Could you explain the logic behind using the integral in simple English, understandable without much education in statistics?

  2. How may I interpret the discrepancy of the results? Am I asking different questions? Is my simulation wrong?

EDIT: I happened to find the answer to the question. I repeated the calculation without the sphere-factor (4/3 * pi), what perfectly recreates the previous answer. I know what is going on. A moderator may delete the question, unless it is found educative. Thanks!

  • $\begingroup$ Since you found the answer, could you answer your own question (and accept it) with a bit more detail? I think this would help others more. See here for details. $\endgroup$ – mhdadk Mar 16 at 13:39
  • $\begingroup$ I can't answer the full question, I just happened to find the root of the discrepancy of results. $\endgroup$ – KaPy3141 Mar 16 at 13:55

Self-answer: The difference between my calculations and the calculation of the answer to my previous question is in the units of [r]. My calculation assumes r to be the distance in real meters in euclidean space. The [r] from the previous question refers to a ratio of sphere radii, setting the (bigger) reference-sphere to a volume of 1 cubic micrometer.

I still don't understand the part of the integral though; I get the exact same distribution using the derivative.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.