skip to main content
article
Free access

Mersenne twister: a 623-dimensionally equidistributed uniform pseudo-random number generator

Published: 01 January 1998 Publication History
  • Get Citation Alerts
  • Abstract

    A new algorithm called Mersenne Twister (MT) is proposed for generating uniform pseudorandom numbers. For a particular choice of parameters, the algorithm provides a super astronomical period of 219937 −1 and 623-dimensional equidistribution up to 32-bit accuracy, while using a working area of only 624 words. This is a new variant of the previously proposed generators, TGFSR, modified so as to admit a Mersenne-prime period. The characteristic polynomial has many terms. The distribution up to v bits accuracy for 1 ≤ v ≤ 32 is also shown to be good. An algorithm is also given that checks the primitivity of the characteristic polynomial of MT with computational complexity O(p2) where p is the degree of the polynomial.
    We implemented this generator in portable C-code. It passed several stringent statistical tests, including diehard. Its speed is comparable to other modern generators. Its merits are due to the efficient algorithms that are unique to polynomial calculations over the two-element field.

    References

    [1]
    BRILLHART, J., LEHMER, D. H., SELFRIDGE, J. L., TUCKERMAN, B., AND WAGSTAFF, S. S., JR. 1988. Factorizations of bn _ 1. 2nd ed., Vol. 22, Contemporary Mathematics. AMS, Providence, R.I.
    [2]
    The hierarchy of correlations in random binary sequences. J. Stat. Phys. 63, 883-896.
    [3]
    COUTURE, R., L'ECUYER, P., AND TEZUKA, S. 1993. On the distribution of k-dimensional vectors for simple and combined Tausworthe sequences. Math. Comput. 60, 749-761.
    [4]
    FERRENBERG, A. M., LANDAU, D. P., AND WONG, Y.J. 1992. Monte Carlo simulations: hidden errors from "good" random number generators. Phys. Rev. Lett. 69, 3382-3384.
    [5]
    FREDRICSSON, S.A. 1975. Pseudo-randomness properties of binary shift register sequences. IEEE Trans. Inf. Theor. 21, 115-120.
    [6]
    FUSHIMI, M. 1990. Random number generation with the recursion xt - xt_3p ~ xt_3q. J. Comput. Appl. Math. 31, 105-118.
    [7]
    FUSHIMI, M. AND TEZUKA, S. 1983. The k-distribution of generalized feedback shift register pseudorandom numbers. Commun. ACM 4, 516-523.
    [8]
    HELLEKALEK, P. 1997. Good random number generators are (not so) easy to find. In Proceedings of the Second IMACS Symposium on Mathematical Modeling (Vienna).
    [9]
    HELLEKALEK, P., AUER, T., ENTACHER, K., LEEB, H., LENDL, O., AND WEGENKITTL, S. The PLAB www-server, http://random.mat.sbg.ac.at. Also accessible via ftp.
    [10]
    HERINGA, J. R., BLOTE, H. W. J., AND COMPAGNER, A. 1992. New primitive trinomials of Mersenne-exponent degrees for random-number generation. Int. J. Modern Phys. C3, 561-564.
    [11]
    KNUTH, D. E. 1981. Seminumerical Algorithms. 2nd ed., Vol. 2, The Art of Computer Programming. Addison Wesley, Reading, MA.
    [12]
    KNUTH, D.E. 1996. Private communication. Keio Univ., Nov. 1996; Jan. 7th 1997.
    [13]
    KNUTH, D. E. 1997. Seminumerical Algorithms. 3rd ed., Vol. 2, The Art of Computer Programming. Addison Wesley, Reading, MA.
    [14]
    L'ECUYER, P. 1994. Uniform random number generation. Ann. Oper. Res. 53, 77-120.
    [15]
    L'ECUYER, P. 1996. Maximally equidistributed combined Tausworthe generators. Math. Comput. 65, 203-213.
    [16]
    LENSTRA, A.K. 1985. Factoring multivariate polynomials over finite fields. J. Comput. Syst. Sci. 30, 235-248.
    [17]
    LENSTRA, A. K., LENSTRA, H. W., JR., AND Lovhsz, L. 1982. Factoring polynomials with rational coefficients. Math. Ann. 261, 515-534.
    [18]
    LEWIS, T. G. AND PAYNE, W. H. 1973. Generalized feedback shift register pseudorandom number algorithms. J. ACM 20, 456-468.
    [19]
    LINDHOLM, J.H. 1968. An analysis of the pseudo-randomness properties of subsequences of long m-sequences. IEEE Trans. Inf. Theor. 14, 569-576.
    [20]
    MARSAGLIA, a. 1985. A current view of random numbers. In Computer Science and Statistics, Proceedings of the Sixteenth Symposium on The Interface, North-Holland, Amsterdam, 3-10.
    [21]
    MARSAGLIA, G. AND ZAMAN, A. 1991. A new class of random number generators. Ann. Appl. Probab. 1, 462-480.
    [22]
    MATSUMOTO, M. AND KURITA, Y. 1992. Twisted GFSR generators. ACM Trans. Model. Comput. Simul. 2, 179-194.
    [23]
    MATSUMOTO, M. AND KURITA, Y. 1994. Twisted GFSR generators II. ACM Trans. Model. Comput. Simul. 4, 254-266.
    [24]
    MATSUMOTO, M. AND KURITA, Y. 1996. Strong deviations from randomness in m-sequences based on trinomials. ACM Trans. Model. Comput. Simul. 6, 99-106.
    [25]
    NIEDERREITER, H. 1993. Factorization of polynomials and some linear-algebra problems over finite fields. Linear Algebra Appl. 192, 301-328.
    [26]
    NIEDERREITER, H. 1995. The multiple-recursive matrix method for pseudorandom number generation. Finite Fields Appl. 1, 3-30.
    [27]
    RUEPPEL, R.A. 1986. Analysis and Design of Stream Ciphers. Communication and Control Engineering Series. Springer-Verlag, New York, NY.
    [28]
    TEZUKA, S. 1990. Lattice structure of pseudorandom sequences from shift register generators. In Proceedings of the 1990 Winter Simulation Conference R. E. Nance Ed. IEEE, 266 -269.
    [29]
    TEZUKA, S. 1994a. The k-dimensional distribution of combined GFSR sequences. Math. Comput. 62, 809-817.
    [30]
    TEZUKA, S. 1994b. A unified view of long-period random number generators. J. Oper. Res. Soc. Japan 37, 211-227.
    [31]
    TEZUKA, S. 1995. Uniform Random Numbers: Theory and Practice. Kluwer.
    [32]
    TEZUKA, S. AND L'ECUYER, P. 1991. Efficient and portable combined Tausworthe random number generators. ACM Trans. Model. Comput. Simul. 1, 99-112.
    [33]
    TEZUKA, S., L'ECUYER, P., AND COUTURE, R. 1993. On the lattice structure of the add-withcarry and subtract-with-borrow random number generators. ACM Trans. Model. Comput. Simul. 3, 315-331.
    [34]
    TOOTILL, J. P. R., ROBINSON, W. D., AND EAGLE, D. J. 1973. An asymptotically random Tausworthe sequence. J. ACM 20, 3, 469-481.

    Cited By

    View all
    • (2024)Kernel density estimation of allele frequency including undetected allelesPeerJ10.7717/peerj.1724812(e17248)Online publication date: 22-Apr-2024
    • (2024)Optimizing implementations of linear layers using two and higher input XOR gatesPeerJ Computer Science10.7717/peerj-cs.182010(e1820)Online publication date: 19-Jan-2024
    • (2024)On the Comprehensive 3D Modeling of the Radiation Environment of Proxima Centauri b: A New Constraint on Habitability?The Astrophysical Journal10.3847/1538-4357/ad2ade964:1(89)Online publication date: 20-Mar-2024
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Transactions on Modeling and Computer Simulation
    ACM Transactions on Modeling and Computer Simulation  Volume 8, Issue 1
    Special issue on uniform random number generation
    Jan. 1998
    102 pages
    ISSN:1049-3301
    EISSN:1558-1195
    DOI:10.1145/272991
    Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 January 1998
    Published in TOMACS Volume 8, Issue 1

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. k-distribution
    2. m-sequences
    3. GFSR
    4. MT19937
    5. Mersenne primes
    6. Mersenne twister
    7. TGFSR
    8. finite fields
    9. incomplete array
    10. inversive-decimation method
    11. multiple-recursive matrix method
    12. primitive polynomials
    13. random number generation
    14. tempering

    Qualifiers

    • Article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)2,896
    • Downloads (Last 6 weeks)410

    Other Metrics

    Citations

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media