<random> uniform_real_distribution with a minimum distance between points

I create a list of coordinates on a square using

#include <random> using namespace std; int main(){ random_device rd; long int seed = rd(); default_random_engine gen(seed); double max=10.0, min=-10.0; uniform_real_distribution<double> uni_real(min,max); double random_x = uni_real(gen); double random_y = uni_real(gen); return 0; } 

I would like to make sure that there is a minimum distance between any two points. For my use, this should be done with periodic boundary conditions.

  • The preferred solution would be the built-in method in the <random> library. Whether there is a?
  • Secondly, any other package that contains a quick way to perform verification (as long as it is easy to use).
  • In the worst case scenario, I can write my own base script, which would be O(n^2) , since I'm not too interested in efficiency right now. If not, there is a simple implementation algorithm that can do this.

Other issues related to the third paragraph or other environment from <random> .

+7
c ++ random
source share
1 answer

While such a selection (which is equivalent to generating non-overlapping circles) is being discussed at math.stackexchange, see https://mathematica.stackexchange.com/questions/2594/efficient-way-to-generate-random-points-with-a-predefined- lower-bound-on-their-p and https://mathematica.stackexchange.com/questions/69649/generate-nonoverlapping-random-circles , I would like to point out another potential solution that includes quasi-random numbers. For quasi-random Sobol sequences, there is a statement stating that there is a minimum positive distance between points that is 0.5*sqrt(d)/N , where d is the dimension of the problem and N is the number of points selected in the hypercube. Paper from the man himself http://www.sciencedirect.com/science/article/pii/S0378475406002382

+2
source share

All Articles