![]() You can find the full test sketch on my GitHub. unsigned long lcg_seed = 0x50000L // Could be any value Based on Mark’s sketch, I repeated his test, but using the simplest, most straightforward “textbook” implementation of LCG, with the parameters used by glibc, which give a LCG model with a theoretical period of 0x7FFFFFFF. I’ll assume here that you are not trying to implement a top-secret high-security encryption scheme on Arduino, but you still want to have a stable, well-behaved and predictable PRNG you can rely on. Otherwise you’ll need to explore alternatives. If you don’t need any kind of predictable periodicity in your stream of random numbers, and don’t care about the long time it takes the default PRNG to run, then you can ignore this issue entirely. There’s something odd about it and it looks to me like their PRNG is not operating properly. Would there be a problem if it’s always 0x7FFFFFFD? Depending on your needs that might not be an issue, but the thing is that it’s such a weird unexpected value, that even if you look into the code behind the PRNG you will end up having no clue of where that value is coming from. And no, it was not I got the same period of 0x7FFFFFFD instead of 0x7FFFFFFF. I did, however, run his same sketch almost verbatim (just added a global time counter) to verify that it wasn’t just an accidental hiccup in his setup that caused his unusual result. Since his experiment takes more than 2 days (55.3 hours, actually) to run on the real hardware, it’s not something I’m interested in playing with a lot (If you repeat the experiment with different seeds and/or different offsets please let me know!).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |