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개)

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.

댓글 수: 1

Thanks Walt,
I fooled around with your suggestion but the transition doesn't seem to be that easy from my two different types of internal states. I'll have to look into why R implements signed ints as the internal states.

댓글을 달려면 로그인하십시오.

Peter Perkins
Peter Perkins 2012년 11월 16일
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.

댓글 수: 1

Hot damn Peter,
You're spot on. I'll turn my attention towards why R is implementing the MRG32k3a differently. Hopefully the difference in internal states doesn't destroy the validity of the generator in R.
Thanks!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2012년 11월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by