F. Senault
1/23/2009 3:34:00 PM
Le 23 janvier 2009 à 15:59, Bart Braem a écrit :
> On Jan 23, 3:34 pm, Lars Christensen <lar...@belunktum.dk> wrote:
>> I do think that my own solution (last on the page) is efficient, but i
>> can't vouch for the statistical properties (it reseeds the Mersenne
>> Twister in Ruby every time a number is drawn, although randomly).
>
> I've tested this setup, with just one RNG. Running my unit tests is
> about 5 times slower, unfortunately. I am calling the random number
> very often, more than 10.000 times in 10 seconds in a simulation that
> uses the standard kernel rand.
> I can't afford this slowdown, but it seems as though there are no
> other solutions that do not use a pure-ruby library?
Can you estimate the number of random numbers you'll need ? Maybe you
could pre-generate sequences of numbers in a few arrays, then patch the
rand method to actually read the array instead of generating the
number ?
The start time and memory consumption will be a lot higher, but maybe it
makes a good compromise ?
Fred
--
I'm broke but I'm happy, I'm poor but I'm kind
I'm short but I'm healthy, yeah
I'm high but I'm grounded, I'm sane but I'm overwhelmed
I'm lost but I'm hopeful, baby (Alanis Morissette, Hand in My Pocket)