我想生成一个从0到2500的束(x,y)坐标,它排除彼此在200之内的点而不递归.
现在我检查所有以前的值列表,看看是否有足够远的所有值.这是非常低效的,如果我需要生成大量的点,它需要永远.
那我该怎么做呢?
我试图生成一个有效的代码,用于生成一些随机位置向量,然后我用它来计算一对相关函数.我想知道是否有直接的方法来设置我的框中任意两点之间允许的最小距离约束.
我的代码目前如下:
def pointRun(number, dr):
"""
Compute the 3D pair correlation function
for a random distribution of 'number' particles
placed into a 1.0x1.0x1.0 box.
"""
## Create array of distances over which to calculate.
r = np.arange(0., 1.0+dr, dr)
## Generate list of arrays to define the positions of all points,
## and calculate number density.
a = np.random.rand(number, 3)
numberDensity = len(a)/1.0**3
## Find reference points within desired region to avoid edge effects.
b = [s for s in …Run Code Online (Sandbox Code Playgroud)