Why does the MRG32k3a return only positive values in the internal state matrix?
이전 댓글 표시
The MRG32k3a random number generator from L'Ecuyer should have internal state vectors of signed long (ranging roughly from -2^31 to 2^31) yet Matlab's implementation is returning unsigned longs as the internal state (0 to 2^32). Is there a way I can mediate the two to run the same seeds on two different programs (i.e. R which uses signed long and Matlab using unsigned)?
Thanks very much, -Clinton
답변 (2개)
Walter Roberson
2012년 11월 15일
I do not know anything about that random generator, but you could experiment with using
typecast(TheUnsignedValue, 'int32')
this would re-interpret the bits as signed.
Peter Perkins
2012년 11월 16일
1 개 추천
The original paper defines the internal state of MRG32k3a as unsigned ints, and the public methods in (what I think is) the reference implementation present the seeds as unsigned ints (although it uses doubles internally for performance reasons). You're right, though, that other implementations use signed ints. However, note that the doc for SSJ describes the constraints on the seed vector as
"the first 3 values of the seed must all be less than m1 = 4294967087, and not all 0; and the last 3 values must all be less than m2 = 4294944443, and not all 0"
My guess would be that, as Walter suggests, you can use TYPECAST, although I can't say for sure what other implementations do internally.
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!