Re: [Boost-users] boost random in 2 dimensions

@Gabriel
From your answer I understand that, the uniform distributed values are generated seperately for x and y axis. Then both should be combined to form a point over a plane.
@Norbert i think this could do uniform distribution only over one co-ordinates. I am assuming you want to sample a point uniformly at random from a rectangular subset of the plane with the sides of the rectangle parallel to the axes. If not, the problem is a little more complex, but still soluble. However, for a square of size 1 Norbert is correct. The extension to a general rectangle is simple - just use two uniform_real_distributions (this will also give you floating point numbers as per your first post). Calls to two different uniform_real_distributions (or successive calls to one object) using the same engine object will give a point uniformly distributed in the rectangle. You are correct to point out that the individual coordinates are also uniformly distributed, but since they are independent they also yield a uniformly distributed point on the rectangle. Robert

On 01/28/2013 10:35 PM, Robert Patterson wrote:
@Norbert i think this could do uniform distribution only over one co-ordinates.
I am assuming you want to sample a point uniformly at random from a rectangular subset of the plane with the sides of the rectangle parallel to the axes. If not, the problem is a little more complex, but still soluble. However, for a square of size 1 Norbert is correct.
I was assuming he uses one uniform_real_distribution to gain two values in [0 1] and use these values (now in a 1x1 square) scaled into the desired rectangle of arbitrary size. Would this result in perfectly random values or would the scaling of the random values introduce some artefacts that might deteriorate the initial randomness? Norbert
participants (2)
-
Norbert Wenzel
-
Robert Patterson