In article <b0idhk0gj3 / enews4.newsguy.com>, > >A couple of questions: >1) how good is Ruby's rand function (what's the quality of randomness)? I >suspec that it is just the same as C's rand, so there won't be a >difference. >2) I'd like to plug in my own random number generator that would probably >produce higher-quality random numbers than the current rand does. I'm >pretty sure it should be doable and easy, like: > >module Kernel > def rand(max=0) > #do random number generation magic here > end >end > Here's what I did. At Robert Feldt's suggestion I used his RandomR package which uses the Mersenne Twister to generate random numbers (a much better method than whatever is built-in, I'm sure). I then redefined rand and srand like so: require 'random/mersenne_twister' module Kernel def rand(max=0) if not defined? @__random @__rng=Random::MersenneTwister.new Time.now.to_i end @__rng.rand(max) end def srand(seed) @__rng=Random::MersenneTwister.new seed end end ....after that everywhere I call rand it uses the Mersenne Twister rng. Phil -- "Or perhaps the truth is less interesting than the facts?" Amy Weiss (accusing theregister.co.uk of engaging in 'tabloid journalism') Senior VP, Communications Recording Industry Association of America