TinyMT Java Implementation

Japanese Version

We introduce TinyMT implemented in Java. TinyMT32, TinyMT64 and ThreadLocalRandom classes are provided.

CAUTION: All three classes are not thread safe. The three classes do not inherit java.util.Random, because Random is designed to be thread safe. The three classes implement the interface, org.apache.commons.math.random.RandomGenerator. Saito is not very good at Java, there might be some bugs left in source files. Please inform Saito of any possible bugs.

There are 65536 parameters for each TinyMT32 and TinyMT64 in resource. ThreadLocalRandom uses TinyMT32 with parameters different from above parameters.

The jump method is provided.

Requirement

The following environment are required to compile and execute this program.

Download

tinymt-1.0.zip

Java doc

TinyMT

Sample

import jp.ac.hiroshima_u.sci.math.saito.tinymt.TinyMT32;

public class Test {
    public static void main(String[] args) {
        TinyMT32 tiny = TinyMT32.getDefault();
	if (args.length > 0) {
	    tiny.setSeed(args[0]);
	}
	for (int i = 0; i < 10; i++) {
	    for (int j = 0; j < 5; j++) {
		System.out.print(String.format("%08x ", tiny.nextInt()));
	    }
	    System.out.println();
	}
    }
}

License

Copyright (c) 2012 Mutsuo Saito, Makoto Matsumoto, Hiroshima
University and The University of Tokyo. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of the Hiroshima University, The University of
      Tokyo nor the names of its contributors may be used to endorse
      or promote products derived from this software without specific
      prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.