Random Number Generators in C
Hello,
I recently got in to Euphoria programming and have run in to a problem
or
two that maybe the List might have answers.
First, Not knowing what the Random Number Generator algorithm built into
Euphoria is and how random it is I went searching for a RNG I could port
into Euphoria. First I found Jeffrey Fielding had included in his Genlib.e
v1.0 a RNG but he did not document the source (or creator) of his RNG.
Which left me in the same boat.
So I tried to port the "Mersenne Twister" RNG which has a period of
(2^19937)-1. It requires a number of bitwise operations. I found Euphoria
does not have bitwise shift functions so I wrote code for that (shift_left
and shift_right --- I'll post these at the RDS site if anyone is
interested), but ran into a brickwall because bitwise operations in
Euphoria are limited to 32 bits. 64 bit XOR, AND, OR operators are required.
Ok. So I went looking for another code snippet that did not require so many
bitwise operations. I found a site that had posted a 17 line code snippet
in C by George Marsaglia (a guru of RNGs). The snippet has 8 different RNGs
but low and behold ran into the same problem the most of these require
64bit bitwise operators.
So what I am looking for is one of the following:
a) a documented RNG with a long period that passes at least in
part
Marsaglia's Diehard Tests
written in Euphoria.
b) a magic bullet that makes Euphoria do 64 bit logical
operations or an
include file that does so.
c) failing these, some help coding a dll in C that will contain
the 8
RNGs noted above.
I won't post the C code for the 8 RNGs unless the List thinks it's a good idea.
|
Not Categorized, Please Help
|
|