Hi, all
Frank Heckenbach wrote:
BTW, GPC's built-in pseduo-random generator ("Mersenne Twister") is also integer based. (The details are available in the source, of course, p/rts/random.pas.)
The Mersenne Twister is a very high quality PRNG, and as Frank says it generates random (8 byte, unsigned) integers, which can then be converted to reals within any desired range. But it isn't the speediest out there. Part of what slows it down is that it generates the numbers in a batch of (?) 640, but doesn't use this batch efficiently. Every time you ask your program for a PRN, it calls the Random function to see if one already exists. It would be faster if it generated an array of 640, exported them, and then the program kept track of whether there was one available.
Most people would never see the difference, and don't want to have to keep count themselves. But some of my programs need several billion PRNs, at which point the function calling overhead is important. For these programs, I moved the storage of the PRN array out into the main program. If you need this kind of quantity of PRNs, I can probably excavate the relevant code.
regards, Toby
Dr. Robert P. Ewing Soil Scientist, Iowa State University