21 Jul
2008
21 Jul
'08
3:57 p.m.
On 21 Jul 2008, at 16:47, Olivier Tournaire wrote:
I am currently using boost::random, and I wonder how it is possible to get uniform random numbers on a union of two intervalls. For instance, I would like to generate uniform_real numbers in the intervall [-a;-b]U[b;a].
Generate a number uniformally in the interval [0,2*(a-b)]. If it is smaller than a-b then add b to it. If it is larger than a-b then multiply it by -1. I think any function which picks the two intervals with equal probability should work. Thanks, Kevin Martin