相关疑难解决方法(0)

生成多个随机(x,y)坐标,不包括重复?

我想生成一个从0到2500的束(x,y)坐标,它排除彼此在200之内的点而不递归.

现在我检查所有以前的值列表,看看是否有足够远的所有值.这是非常低效的,如果我需要生成大量的点,它需要永远.

那我该怎么做呢?

python random math coordinates

24
推荐指数
2
解决办法
3万
查看次数

如何使用numpy.random.rand设置生成点的最小距离约束?

我试图生成一个有效的代码,用于生成一些随机位置向量,然后我用它来计算一对相关函数.我想知道是否有直接的方法来设置我的框中任意两点之间允许的最小距离约束.

我的代码目前如下:

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)

python random numpy distribution correlation

8
推荐指数
2
解决办法
1233
查看次数

标签 统计

python ×2

random ×2

coordinates ×1

correlation ×1

distribution ×1

math ×1

numpy ×1