Pergunta

I am trying to implement and optimize the Tiny Mersenne Twister (TinyMT) algorithm as required by an API I am developing with my team at work. The algorithm utilizes a C structure with 32-bit unsigned integers "mat1", "mat2", "tmat", and an array called "status" which is four 32-bit unsigned integers wide.

I am relatively new to the subject of random number generation; however, I have been able to teach myself a lot about the subject over the past couple of weeks. I know what the purpose of a seed is, different methods such as linear congruent, LSFR, GFSR, etc. So I've been doing my "homework" and researching the topic to the best of my ability (contrary to what the guys at Stack Overflow think). Unfortunately, the Mersenne Twister in general is extremely poorly documented and very few documents exist to explain the code and math side-by-side. The TinyMT's documentation is even worse, it's virtually non-existent! So developing accurate Doxygen comments for this part of the API is going to be tricky.

With that said, hopefully somebody more qualified than I can help me out here. What is the significance of the aforementioned parameters? What do they do, what do they mean, what do they stand for, etc? My guess would be as follows:

  • mat1 - Matrix 1
  • mat2 - Matrix 2
  • tmat - Tempering Matrix
  • status - 127 bit wide "seed" (where the last bit goes, I'm not sure)

Given that the user provides values for "mat1", "mat2", and "tmat," are there any precautions they need to take before supplying values for them? Again, this is for an API and its documentation, so I would like to be able to give the customers a good idea of what they need to use the RNG and hopefully make the lives of other fellow programmers easier. Thanks!

Foi útil?

Solução

You can generate parameters for the PRNG using the provided program tinymt32dc. You should generate these parameters once and for all for each application. Each time you call the PRNG, you use the same parameters but a different seed. The reason that you don't want to vary the parameters is that generating them is (apparently) time consuming, while initializing the PRNG from just the seed is designed to be quick.

There might be some constraints on these parameters, but since you're not the designer of TinyMT, you're not aware of them. Instead, you should just use the provided program that generates legal parameters.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a cs.stackexchange
scroll top