public class Antithetic extends java.lang.Object implements RandomNumber
Given an instance of a RandomNumber, construct an instance of Antithetic using a copy of the given RandomNumber instance. Then a draw from the given RandomNumber and the Antithetic will be antithetic random numbers. (The draw from Antithetic will be 1- the draw from the original.)
This relationship only remains true if the same number of draws are made from each. Therefore, if the original RandomNumber and the Antithetic are used as the supporting RandomNumbers for 2 RandomVariates in order to get negatively correlated streams, the implementation of the RandomVariate must use the same number of RandomNumbers for each RandomVariate draw (like an inverse transform implementation). If an implementation that uses a random number of RandomNumber draws is used (like accept/reject), then the synchronization will be lost causing the negative correlation to be lost.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
DEFAULT_DELEGATE
The default is currently Congruential.
|
protected RandomNumber |
delegate
The supporting RandomNumber instance.
|
Constructor and Description |
---|
Antithetic()
Creates a new Antithetic based on an new instance of the default RandomNumber.
|
Antithetic(RandomNumber delegate)
Creates a new Antithetic based on the given RandomNumber.
|
Modifier and Type | Method and Description |
---|---|
double |
draw()
Draws a random number and returns it as U(0,1)
|
long |
drawLong()
Draws a random number and returns it as an integer.
|
double |
getMultiplier()
Returns the value for this RandomNumber needed to scale
a number produced by drawLong to result in U(0,1).
|
RandomNumber |
getRandomNumber() |
long |
getSeed()
Gets the current value of the seed of the supporting RandomNumber.
|
long[] |
getSeeds()
Gets the current (not original) value of the seeds for this RandomNumber.
|
void |
resetSeed()
Sets the seed to the value of the last setSeed.
|
void |
setRandomNumber(RandomNumber rng)
If the desire
is to create 2 antithetic random number streams, then the RandomNumber
instance supplied should be a copy of the original.
|
void |
setSeed(long seed)
Sets the seed of the supporting RandomNumber.
|
void |
setSeeds(long[] seeds)
Sets the seeds of this RandomNumber to the given values.
|
java.lang.String |
toString()
Returns a String containing the name of this RandomNumber.
|
protected static final java.lang.String DEFAULT_DELEGATE
protected RandomNumber delegate
public Antithetic()
public Antithetic(RandomNumber delegate)
delegate
- given RandomNumberpublic void setRandomNumber(RandomNumber rng)
rng
- the instance of the supporting RandomNumber.public RandomNumber getRandomNumber()
public void setSeed(long seed)
setSeed
in interface RandomNumber
seed
- The new random number seedpublic long getSeed()
getSeed
in interface RandomNumber
public void resetSeed()
resetSeed
in interface RandomNumber
public double draw()
RandomNumber
draw
in interface RandomNumber
public void setSeeds(long[] seeds)
RandomNumber
setSeeds
in interface RandomNumber
seeds
- The new array of seedspublic long[] getSeeds()
RandomNumber
getSeeds
in interface RandomNumber
public java.lang.String toString()
toString
in class java.lang.Object
public double getMultiplier()
RandomNumber
getMultiplier
in interface RandomNumber
public long drawLong()
RandomNumber
drawLong
in interface RandomNumber