IIRC Maxima's MT implement generates chunks of 32 bits at a time,
and uses those to construct the output which is some number
of bits wide. For each N-bit output, Maxima uses 1 + floor(N/32) chunks.
Any leftover bits are thrown away (not used for the next output).
All correct implementations of MT19937 should yield the same output
given the same initial state, should they not?
(Otherwise, it would seem, the nice properties of MT prng's aren't guaranteed.)
best,
Robert Dodier
On 1/20/11, Raymond Toy <toy.raymond at gmail.com> wrote:
> On 1/19/11 1:55 PM, Matthew Gwynne wrote:
>> Hi,
>>
>> documentation suggests is used for the Maxima random number
>> generator), so it seems it should be easy, however, it's not clear
>> exactly how Maxima extracts integers from the state of the Mersenne
>> twister, or precisely the implementation of the random_permutation
>> function even if the random number generation were the same.
> Maxima's implemention is in the file src/rand-mt19937.lisp. From a
> quick look at the code, a large integer is obtained by just
> concatenating a bunch of 32-bit integers produced by the generator. The
> first generated value is in the least significant position.
>
>>
>> P.S - As a note, in the coming C++ standard there will be random
>> number generators and so on guaranteed by the standard library, and so
>> it might make sense if simply using std::random_shuffle with the
>> standard number generator yielded the same results as
>> random_permutation in Maxima? This would make a description of the
>> behaviour in the documentation very simple, as one could just point to
>> the more elaborated C++ standard.
> That doesn't really help. Maxima is not written in C++.
>
> If the algorithm is described, perhaps we could use the same algorithm.
> But if it's different from what maxima already uses, then it might also
> break existing code. So, unless maxima's version is broken, I think we
> should keep maxima's implementation as is.
>
> Ray
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>