|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfern.tools.Stochastics
public class Stochastics
Manages a random number generators for various distributions. By only using this class for every random number drawing in the whole framework, some advantages emerge:
setSeed(Date)
Method Summary | |
---|---|
int |
getBinom(int i,
double prob)
Gets a random number from the binomial distribution. |
int[] |
getCounts()
Gets the number of random number generations for each distribution (same order as in getNames() since the last call of resetCounts . |
double |
getExponential(double d)
Gets a random number from the exponential distribution. |
static Stochastics |
getInstance()
Singleton pattern method. |
String[] |
getNames()
Gets the names of the built-in distributions. |
double |
getNormal()
Gets a random number from the Normal distribution |
double |
getNormal(double mean,
double stddev)
Gets a random number from the Normal distribution with given mean and stddev. |
int |
getPoisson(double mean)
Gets a random number from the Poisson distribution. |
long |
getSeed()
Gets the actual seed of the random number generator. |
double |
getUnif()
Gets a random number from the uniform distribution between 0 and 1. |
int |
getUnif(int min,
int max)
Gets a uniformly chosen random number between min (inclusive) and max (exclusive) |
boolean |
isCountGenerations()
Gets whether or not to count the number of random number generations |
void |
resetCounts()
Resets the counts for each distribution to zero. |
void |
resetSeed()
Sets the seed to the current date |
void |
setCountGenerations(boolean countGenerations)
Sets whether or not to count the number of random number generations |
void |
setSeed(Date seed)
Sets a new seed for the random number generator. |
void |
setSeed(long seed)
Sets a new seed for the random number generator. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Stochastics getInstance()
public void resetSeed()
public long getSeed()
public void setSeed(long seed)
seed
- the seedpublic void setSeed(Date seed)
seed
- the seedpublic boolean isCountGenerations()
public void setCountGenerations(boolean countGenerations)
countGenerations
- whether or not to countpublic int[] getCounts()
getNames()
since the last call of resetCounts
.
public String[] getNames()
public void resetCounts()
public double getUnif()
Uniform.nextDouble()
public double getExponential(double d)
d
- mean
Exponential.nextDouble()
public int getBinom(int i, double prob)
i
- sizeprob
- probability
Binomial.nextInt(int, double)
public int getUnif(int min, int max)
min
(inclusive) and max
(exclusive)
min
- inclusive minimummax
- exclusive maximum
Uniform.nextIntFromTo(int, int)
public int getPoisson(double mean)
mean
- mean
Poisson.nextInt(double)
public double getNormal()
Normal.nextDouble()
public double getNormal(double mean, double stddev)
mean
- the meanstddev
- the stddev
Normal.nextDouble(double, double)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |