RandomR - Pseudo-random generators for Ruby

Version:          0.1.1
Release date:     2001-11-28
Home page:        http://rubyvm.sf.net/subprojects/randomr
Tarball:          http://prdownloads.sf.net/rubyvm/randomr-0-1-1.tar.gz
Author:           Robert Feldt
Email:            feldt@ce.chalmers.se

What is it?

Pseudo-random number generators (PRNG) for Ruby. Includes a very fast C implementation of the Mersenne Twister, which is a very good PRNG. It has a period of 2**19937-1 and is equi-distributed in 623 dimensions!

Why?

Ruby's rand/srand have a number of drawbacks:

RandomR addresses all these problems but the crypto-safety which is still on the todo.

Installation?

  1. unpack tarball (if you haven't already)
  2. ruby make.rb
  3. ruby install.rb

Example of use?

        require 'random/mersenne_twister'
        mt = Random::MersenneTwister.new 4357
        mt.rand(0)       # => 0.424325522
        mt.rand(10)      # => 9

Requirements?

ANSI C compiler and Ruby.

I've successfully used RandomR with Ruby 1.7.1 (2001-09-20) and cygwin 1.1.8 (gcc version 2.95.2-5 19991024) on Windows 2000 Professional Workstation. If it works for you on other platforms/setups I'd appreciate if you drop me a note. However, it should work on most Ruby-enabled platforms having a C compiler.

NOTE THAT THIS IS AN ALPHA RELEASE SO THERE MIGHT BE BUGS.

Documentation?

None yet. The API is very simple and can be found in the file random.rb. Also check out the tests.

For the future?

Maybe crypto-strong randomness generation and more algorithms but its not a high priority. Focus in on getting the API right and the MersenneTwister really fast and correct. I think we're close on all these aspects with this version 0.2.0.

License and legal issues?

RandomR is

Copyright (c) 2001 Robert Feldt, feldt@ce.chalmers.se All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

The code for the Mersenne Twister is based on MersenneTwister.h by Richard Wagner. The original code included the following notice:

Copyright (C) 2001 Richard J. Wagner

The original code included the following notice:

       Copyright (C) 1997, 1999 Makoto Matsumoto and Takuji Nishimura.
       When you use this, send an email to: matumoto@math.keio.ac.jp
       with an appropriate reference to your work.

It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu when you write.

Do you have comments or questions?

I'd appreciate if you drop me a note if you're successfully using RandomR. If there are some known users I'll be more motivated to packing up additions / new versions and post them to RAA.

Happy coding!

Robert Feldt, feldt@ce.chalmers.se