我想随机均匀分布生成n个点,使得任意点之间的距离大于某个固定值。
以下是我在MATLAB中的场景:
xr = rand(1, M)
,M红点的y坐标为yr = rand(1, M)
。 xb = rand(1, M)
和yb = rand(1, M)
。然后,我计算所有点之间的距离如下:
x = [xr, xb];
y = [yr, yb];
D = sqrt(bsxfun(@minus, x, x').^2 + bsxfun(@minus, y, y').^2);
d = D(1:M, M + 1:end);
d
限制为始终大于某个给定值,例如d0=0.5
。怎么做?
答案 0 :(得分:1)
虽然在math.stackexchange上讨论了这样的采样(相当于非重叠圆生成),但请参阅https://mathematica.stackexchange.com/questions/2594/efficient-way-to-generate-random-points-with-a-predefined-lower-bound-on-their-p和https://mathematica.stackexchange.com/questions/69649/generate-nonoverlapping-random-circles,我想指出另一个涉及准的另一种可能的解决方案 - 随机数。对于准随机Sobol序列,有一个陈述表明点之间的最小正距离等于filename: .asciiz "data.txt"
textBuffer: .word 255
,其中0.5*sqrt(d)/N
是问题的维度,d
是在超立方体中采样的点。该男子自己的论文http://www.sciencedirect.com/science/article/pii/S0378475406002382