Boost logo

Boost Users :

Subject: Re: [Boost-users] boost random in 2 dimensions
From: Robert Patterson (riap_at_[hidden])
Date: 2013-01-28 16:35:00


@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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net