Re: Mersenne Twister
- Posted by rforno at tutopia.com Sep 22, 2001
- 383 views
Oh, well, we don't need that for the Mersenne Twister. And of course this would be sloooowwww... ----- Original Message ----- From: "Kat" <gertie at PELL.NET> To: "EUforum" <EUforum at topica.com> Subject: Re: Mersenne Twister > > On 21 Sep 2001, at 17:02, rforno at tutopia.com wrote: > > > > > Derek: > > As per your request, I revised your implementation of the Mersenne Twister. I > > found a slight disagreement with the original. The original poses: seed & > > 0xffffffff You instead code: remainder(seed, #FFFFFFFF) This does not give the > > same result for numbers >= 2^32 - 1, as should be most of the numbers generated > > by multiplying the previous one by 69069. Of course Euphoria does not accept: > > and_bits(seed, #100000000), but: remainder(seed, #100000000) is Ok and gives the > > same result. Maybe the initial matrix is not so important, as stated elsewhere, > > and your variant is perhaps better, since the original generates only odd > > numbers, and yours generates odd and even numbers nearly at random, but only to > > stick to the original...:) A similar problem occurs with the final result. The > > maximum value that y + #80000000 can attain is #FFFFFFFFF, and in this case the > > result is 1 higher than "range". This is equally solved by substituting range / > > #10000000 instead of range / #FFFFFFFF. Even it may be preferable to write (y + > > #80000000) / #100000000 * range, to protect against inaccuracies of the division > > of range by 2^32. Maybe Rob has something to say about it. Best regards. > > What about using string math? You can then build as big a number as you > wish, in an object used as a sequence? > > x = "0283650813749136548740623403784650278362456"--ad infinitum > return(x) > > Kat > > >