Mersenne Twister Seeding and UUIDs
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Mon Jun 11 10:32:41 PDT 2012
On 11/06/12 18:15, Johannes Pfau wrote:
> Am Sun, 10 Jun 2012 00:24 +0100
> schrieb Andrew Talbot<andrew.talbot at talbotville.com>:
>
>> Forgive what may be the unintelligible ramblings of an ignorant
>> hobbyist, but, if I am not mistaken, the Mersenne Twister
>> implementation in std.random currently can be seeded only with a
>> 32-bit unsigned integer, which I presume gives it 2^32 starting
>> points, whereas I believe there should also be an alternative option
>> to seed it with an array of up to 624 uintS, so that potentially it
>> can be started in any one of its 19,937 internal states. I may be
>> wrong, but I believe that to have instant access to enough of the
>> "state space" to be able to generate a large number of unique random
>> UUIDs this second seeding option may be necessary.
>>
>
> Could someone who's familiar with RNGs answer this question? This seems
> to be important for st.uuid, we should get this right.
In the Boost C++ implementation it certainly accepts a range as input:
template<class It>
void seed(It& first, It last)
{
int j;
for(j = 0; j < n && first != last; ++j, ++first)
x[j] = *first;
i = n;
if(first == last && j < n)
throw std::invalid_argument("mersenne_twister::seed");
}
Some information on the seeding issue can be found here:
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
More information about the Digitalmars-d
mailing list