|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.random.AbstractRandomGenerator
jp.ac.hiroshima_u.sci.math.saito.tinymt.TinyMT32
public final class TinyMT32
TinyMT is a pseudo random number generator.
To get an instance, call getDefault()
,
getDefault(long)
, getDefault(String)
or getDefault(int[])
.
This class is not synchronized, One way to use TinyMT in concurrent environment is to use an instance per a thread.
This class supports jump function. User can get an array of pseudo random
number generators by calling
getDefaultArray(int, long, long)
, or
getDefaultArray(int, String, long)
.
This class supports discrete characteristic polynomial generators. User can
get an array of pseudo random number generators whose characteristic
polynomials are discrete by calling
getTinyMTArray(int, long)
.
Method Summary | |
---|---|
java.lang.String |
getCharacteristic()
return characteristic polynomial in hexadecimal format. |
static TinyMT32 |
getDefault()
Factory method which returns the TinyMT with the first generated parameter of TinyMTDC. |
static TinyMT32 |
getDefault(int[] seeds)
get default TinyMT32 with seeding by array. |
static TinyMT32 |
getDefault(long seed)
Factory method which returns the TinyMT with the first generated parameter of TinyMTDC. |
static TinyMT32 |
getDefault(java.lang.String seed)
Factory method which returns the TinyMT with the first generated parameter of TinyMTDC. |
static TinyMT32[] |
getDefaultArray(int count,
long seed,
long jump)
make and return an array of TinyMT. |
static TinyMT32[] |
getDefaultArray(int count,
java.lang.String seed,
long jump)
Make and return an array of TinyMT. |
int |
getDelta()
return Delta of TinyMT. |
int |
getId()
return ID of TinyMT. |
TinyMT32[] |
getJumpedArray(int count,
long jump)
Make and return an array of TinyMT. |
static TinyMT32[] |
getTinyMTArray(int count,
long seed)
Make and return an array of TinyMT. |
int |
getWeight()
return Hamming weight of characteristic polynomial of TinyMT. |
double |
nextDouble()
returns double r, 0 <= r < 1.0. |
float |
nextFloat()
returns float r, 0 <= r < 1.0. |
int |
nextInt()
returns 32-bit integer. |
long |
nextLong()
returns 64-bit integer. |
void |
setSeed(int seed)
internal set seed function This seeding is compatible with C language implementation. |
void |
setSeed(int[] seeds)
seeding by array of integers. |
void |
setSeed(long seed)
initialize internal state by seed. |
void |
setSeed(java.lang.String seed)
seeding by string, This will be convenient. |
Methods inherited from class org.apache.commons.math.random.AbstractRandomGenerator |
---|
clear, nextBoolean, nextBytes, nextGaussian, nextInt |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public int nextInt()
nextInt
in interface org.apache.commons.math.random.RandomGenerator
nextInt
in class org.apache.commons.math.random.AbstractRandomGenerator
public long nextLong()
nextLong
in interface org.apache.commons.math.random.RandomGenerator
nextLong
in class org.apache.commons.math.random.AbstractRandomGenerator
public void setSeed(long seed)
setSeed
in interface org.apache.commons.math.random.RandomGenerator
setSeed
in class org.apache.commons.math.random.AbstractRandomGenerator
seed
- seed of randomnesspublic void setSeed(java.lang.String seed)
seed
- seed of pseudo random numberspublic void setSeed(int[] seeds)
setSeed
in interface org.apache.commons.math.random.RandomGenerator
setSeed
in class org.apache.commons.math.random.AbstractRandomGenerator
seeds
- seeds of pseudo random numbers.public void setSeed(int seed)
setSeed
in interface org.apache.commons.math.random.RandomGenerator
setSeed
in class org.apache.commons.math.random.AbstractRandomGenerator
seed
- seed of pseudo random numberspublic static TinyMT32 getDefault(java.lang.String seed)
seed
- seed of pseudo random numbers.
public static TinyMT32 getDefault(long seed)
seed
- seed of pseudo random numbers.
public static TinyMT32 getDefault(int[] seeds)
seeds
- seeds for initialization.
public static TinyMT32 getDefault()
System.nanoTime()
and
Thread.getId()
are used for seed.
public static TinyMT32[] getDefaultArray(int count, long seed, long jump)
count
- number of TinyMT to be created.seed
- seed of first elementjump
- step is jump * 264
public static TinyMT32[] getDefaultArray(int count, java.lang.String seed, long jump)
count
- number of TinyMT to be created.seed
- seed of first elementjump
- step is jump * 264
public TinyMT32[] getJumpedArray(int count, long jump)
Note: Do not call any setSeed methods after jump. Seeding will cancel the effect of jump.
count
- number of arraysjump
- jump step
public static TinyMT32[] getTinyMTArray(int count, long seed) throws java.io.IOException
getJumpedArray(int, long)
using each element and can get more TinyMTs.
Calling setSeed for each element is O.K and is a nice idea to assure independency.
count
- number of TinyMT you want.seed
- seed of each element
count
java.io.IOException
- when can't read resource file.public double nextDouble()
nextDouble
in interface org.apache.commons.math.random.RandomGenerator
nextDouble
in class org.apache.commons.math.random.AbstractRandomGenerator
public float nextFloat()
nextFloat
in interface org.apache.commons.math.random.RandomGenerator
nextFloat
in class org.apache.commons.math.random.AbstractRandomGenerator
public java.lang.String getCharacteristic()
public int getId()
public int getDelta()
public int getWeight()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |