Boost logo

Boost Users :

Subject: Re: [Boost-users] [random] Bias in boost::random generators?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-05-24 10:03:20


AMDG

Tiago de Paula Peixoto wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Steven Watanabe wrote:
>
>>> I obtain similar results with other generators, except with
>>> minstd_rand, where the sequences from both libraries are the
>>> same. This lead me to conclude that the problem is with the
>>> generators themselves, not with uniform_int<>.
>>>
>>>
>> The problem is in uniform_int<>. The behavior of uniform_int depends
>> on the range of the generator.
>>
>
> It is true, I don't see this problem when using a uniform_real<>
> distribution. But I do see it with uniform_smallint<> as well.
>
> In any case, uniform_int<> and uniform_smallint<> are quite broken, if
> they can't be uniform for such a small range.
>

In uniform_smallint, the bias is intentional. You should only use it if you
are willing to accept the bias to gain performance. For such a small
range, they
are both "close" to being uniform, but because of the way you are using
it, the bias is magnified. If you just counted the number of each
value, the
difference should not be huge.

In Christ,
Steven Watanabe


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