IDEAS home Printed from https://ideas.repec.org/c/cod/octave/c021101.html
 

RANDMT: Octave function to produce random numbers via Mersenne twister

Author

Listed:
  • Shawn Cokus
  • Makoto Matsumoto
  • Takuji Nishimura
  • Dirk Eddelbuettel

Programming Language

Octave

Abstract

The file randmt.cc provides three new commands for GNU Octave:randmt to generate U(0,1) random numbers, randmtn to generate N(0,1) random numbers, and randmtseed to set the seed of the generator. The actual ANSI C implementation of the RNG is provided by the file cokus.c (also included in the tarball), written by Shawn Cokus. This is an improved implementation of the very long period, fast, and memory-efficient Mersenne Twister Random Number Generator by Makoto Matsumoto and Takuji Nishimura. This random number generator uses a twisted generalized feedback shift-register algorithm which has a Mersenne prime period of 2^19937 - 1, or about 10^6000, and is equi-distributed in 623 dimensions. It has passed the `DIEHARD' statistical tests by Marsaglia, but is also extremely fast and efficient in terms of memory usage. The code has been tested on 32bit (i386) and 64bit (alpha) versions of Linux. Beyond the actual MT implementation by Shawn Cokus, one routine from the RANDLIB library (Brown, Lovato, Russell, Venier, 1997, available at MDACC) was used to tranform uniform into standard normal deviates. This is the Ahrens and Dieter (1973) algorithm. I have simply combined the pieces, and provided simple C++ wrappers so that Octave can access this code. Also included are a Makefile, and a simple Octave script to time the MT RNG against Octave's default RNG from RANDLIB. Provided mkoctfile is in your PATH, you can just type make to build the Octave modules randmt.oct, randmtn.oct, and randmtseed.oct. The `compare_rngs.m' Octave script can be used to time this RNG against the default RNG.

Suggested Citation

  • Shawn Cokus & Makoto Matsumoto & Takuji Nishimura & Dirk Eddelbuettel, 2000. "RANDMT: Octave function to produce random numbers via Mersenne twister," Octave codes C021101, .
  • Handle: RePEc:cod:octave:c021101
    as

    Download full text from publisher

    To our knowledge, this item is not available for download. To find whether it is available, there are three options:
    1. Check below whether another version of this item is available online.
    2. Check on the provider's web page whether it is in fact available.
    3. Perform a search for a similarly titled item that would be available.

    More about this item

    Keywords

    Octave;

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:cod:octave:c021101. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: the person in charge (email available below). General contact details of provider: .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.