HE_Mesh  6.0.1
wblut.math.WB_MTRandom Class Reference
+ Inheritance diagram for wblut.math.WB_MTRandom:

Public Member Functions

Object clone () throws CloneNotSupportedException
 
boolean stateEquals (final Object o)
 
void readState (final DataInputStream stream) throws IOException
 
void writeState (final DataOutputStream stream) throws IOException
 
 WB_MTRandom ()
 
 WB_MTRandom (final long seed)
 
synchronized void setSeed (final long seed)
 
synchronized void reset ()
 
final int nextInt ()
 
final short nextShort ()
 
final char nextChar ()
 
final boolean nextBoolean ()
 
final boolean nextBoolean (final float probability)
 
final boolean nextBoolean (final double probability)
 
final byte nextByte ()
 
final void nextBytes (final byte[] bytes)
 
final long nextLong ()
 
final long nextLong (final long n)
 
final double nextDouble ()
 
final double nextCenteredDouble ()
 
final double nextGaussian ()
 
final float nextFloat ()
 
final float nextCenteredFloat ()
 
final int nextInt (final int n)
 

Private Attributes

int mt []
 
int mti
 
int mag01 []
 
double __nextNextGaussian
 
boolean __haveNextNextGaussian
 
long seed
 

Static Private Attributes

static final long serialVersionUID = 3636987267914792302L
 
static final int N = 624
 
static final int M = 397
 
static final int MATRIX_A = 0x9908b0df
 
static final int UPPER_MASK = 0x80000000
 
static final int LOWER_MASK = 0x7fffffff
 
static final int TEMPERING_MASK_B = 0x9d2c5680
 
static final int TEMPERING_MASK_C = 0xefc60000
 

Constructor & Destructor Documentation

wblut.math.WB_MTRandom.WB_MTRandom ( )

Constructor using the default seed.

wblut.math.WB_MTRandom.WB_MTRandom ( final long  seed)

Constructor using a given seed. Though you pass this seed in as a long, it's best to make sure it's actually an integer.

Parameters
seedthe seed

References wblut.math.WB_MTRandom.setSeed().

Member Function Documentation

Object wblut.math.WB_MTRandom.clone ( ) throws CloneNotSupportedException
final boolean wblut.math.WB_MTRandom.nextBoolean ( final float  probability)

This generates a coin flip with a probability probability of returning true, else returning false. probability must be between 0.0 and 1.0, inclusive. Not as precise a random real event as nextBoolean(double), but twice as fast. To explicitly use this, remember you may need to cast to float first.

Parameters
probabilitythe probability
Returns
next random coin flip

References wblut.math.WB_MTRandom.LOWER_MASK, wblut.math.WB_MTRandom.M, wblut.math.WB_MTRandom.mag01, wblut.math.WB_MTRandom.mt, wblut.math.WB_MTRandom.N, wblut.math.WB_MTRandom.TEMPERING_MASK_B, and wblut.math.WB_MTRandom.TEMPERING_MASK_C.

final boolean wblut.math.WB_MTRandom.nextBoolean ( final double  probability)

This generates a coin flip with a probability probability of returning true, else returning false. probability must be between 0.0 and 1.0, inclusive.

Parameters
probabilitythe probability
Returns
next random coin flip

References wblut.math.WB_MTRandom.LOWER_MASK, wblut.math.WB_MTRandom.M, wblut.math.WB_MTRandom.mag01, wblut.math.WB_MTRandom.mt, wblut.math.WB_MTRandom.N, wblut.math.WB_MTRandom.TEMPERING_MASK_B, and wblut.math.WB_MTRandom.TEMPERING_MASK_C.

final void wblut.math.WB_MTRandom.nextBytes ( final byte[]  bytes)
final double wblut.math.WB_MTRandom.nextCenteredDouble ( )

Returns a random double in the half-open range from [-0.5,0.5). Thus -0.5 is a valid result but 0.5 is not.

Returns
next random double in range [-0.5,0.51)

References wblut.math.WB_MTRandom.nextDouble().

final float wblut.math.WB_MTRandom.nextCenteredFloat ( )

Returns a random float in the half-open range from [-0.5,0.5). Thus -0.5 is a valid result but 0.5 is not.

Returns
next random float in range [-0.5,0.5)

References wblut.math.WB_MTRandom.nextFloat().

final double wblut.math.WB_MTRandom.nextDouble ( )

Returns a random double in the half-open range from [0.0,1.0). Thus 0.0 is a valid result but 1.0 is not.

Returns
next random double in range [0,1)

References wblut.math.WB_MTRandom.LOWER_MASK, wblut.math.WB_MTRandom.M, wblut.math.WB_MTRandom.mag01, wblut.math.WB_MTRandom.mt, wblut.math.WB_MTRandom.N, wblut.math.WB_MTRandom.TEMPERING_MASK_B, and wblut.math.WB_MTRandom.TEMPERING_MASK_C.

final float wblut.math.WB_MTRandom.nextFloat ( )

Returns a random float in the half-open range from [0.0f,1.0f). Thus 0.0f is a valid result but 1.0f is not.

Returns
next random float in range [0,1)

References wblut.math.WB_MTRandom.LOWER_MASK, wblut.math.WB_MTRandom.M, wblut.math.WB_MTRandom.mag01, wblut.math.WB_MTRandom.mt, wblut.math.WB_MTRandom.N, wblut.math.WB_MTRandom.TEMPERING_MASK_B, and wblut.math.WB_MTRandom.TEMPERING_MASK_C.

final int wblut.math.WB_MTRandom.nextInt ( final int  n)

Returns an integer drawn uniformly from 0 to n-1. Suffice it to say, n must be > 0, or an IllegalArgumentException is raised.

Parameters
nthe n
Returns
next random integer in range 0 to n-1.

References wblut.math.WB_MTRandom.LOWER_MASK, wblut.math.WB_MTRandom.M, wblut.math.WB_MTRandom.mag01, wblut.math.WB_MTRandom.mt, wblut.math.WB_MTRandom.N, wblut.math.WB_MTRandom.TEMPERING_MASK_B, and wblut.math.WB_MTRandom.TEMPERING_MASK_C.

final long wblut.math.WB_MTRandom.nextLong ( final long  n)

Returns a long drawn uniformly from 0 to n-1. Suffice it to say, n must be > 0, or an IllegalArgumentException is raised.

Parameters
nthe n
Returns
next random long between 0 and n-1

References wblut.math.WB_MTRandom.LOWER_MASK, wblut.math.WB_MTRandom.M, wblut.math.WB_MTRandom.mag01, wblut.math.WB_MTRandom.mt, wblut.math.WB_MTRandom.N, wblut.math.WB_MTRandom.TEMPERING_MASK_B, and wblut.math.WB_MTRandom.TEMPERING_MASK_C.

void wblut.math.WB_MTRandom.readState ( final DataInputStream  stream) throws IOException

Reads the entire state of the MersenneTwister RNG from the stream.

Parameters
streamthe stream
Exceptions
IOExceptionSignals that an I/O exception has occurred.
synchronized void wblut.math.WB_MTRandom.reset ( )
synchronized void wblut.math.WB_MTRandom.setSeed ( final long  seed)

Initalize the pseudo random number generator. Don't pass in a long that's bigger than an int (Mersenne Twister only uses the first 32 bits for its seed).

Parameters
seedthe new seed

References wblut.math.WB_MTRandom.MATRIX_A, wblut.math.WB_MTRandom.mti, wblut.math.WB_MTRandom.N, and wblut.math.WB_MTRandom.seed.

boolean wblut.math.WB_MTRandom.stateEquals ( final Object  o)
void wblut.math.WB_MTRandom.writeState ( final DataOutputStream  stream) throws IOException

Writes the entire state of the MersenneTwister RNG to the stream.

Parameters
streamthe stream
Exceptions
IOExceptionSignals that an I/O exception has occurred.

Member Data Documentation

boolean wblut.math.WB_MTRandom.__haveNextNextGaussian
private
double wblut.math.WB_MTRandom.__nextNextGaussian
private
final int wblut.math.WB_MTRandom.LOWER_MASK = 0x7fffffff
staticprivate
final int wblut.math.WB_MTRandom.M = 397
staticprivate
int wblut.math.WB_MTRandom.mag01[]
private
final int wblut.math.WB_MTRandom.MATRIX_A = 0x9908b0df
staticprivate
int wblut.math.WB_MTRandom.mt[]
private
int wblut.math.WB_MTRandom.mti
private
final int wblut.math.WB_MTRandom.N = 624
staticprivate
long wblut.math.WB_MTRandom.seed
private
final long wblut.math.WB_MTRandom.serialVersionUID = 3636987267914792302L
staticprivate
final int wblut.math.WB_MTRandom.TEMPERING_MASK_B = 0x9d2c5680
staticprivate
final int wblut.math.WB_MTRandom.TEMPERING_MASK_C = 0xefc60000
staticprivate
final int wblut.math.WB_MTRandom.UPPER_MASK = 0x80000000
staticprivate

The documentation for this class was generated from the following file: