Class NumberRandom
java.lang.Object
com.adriangarcia.metaheuristics.tsmbfoa.NumberRandom
This class is used to generate pseudo-random numbers from the Java Random
class. Two instances of the Random class are realized in the class,
the first uses a 48-bit seed by default and the second one uses
a customized seed with up to 64 bits as the initial value.
- Version:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new random number generator, sets the seed with the current time in milliseconds, is returned by method:currentTimeMillis()
NumberRandom
(long seed) Creates a new pseudo-random number generator, using a single seed:long
. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getRandomRankUnif
(double min, double max) Returns adouble
uniformly distributed pseudo-random with specified range.int
getRandomRankUnif
(int min, int max) Returns aint
uniformly distributed pseudo-random with specified range.double
Returns adouble
uniformly distributed pseudo-random, between 0.0 and 1.0void
setRandom
(long seed) Adjusts the seed of the pseudo-random number generator, using a single seed:long
.
-
Constructor Details
-
NumberRandom
public NumberRandom()Creates a new random number generator, sets the seed with the current time in milliseconds, is returned by method:currentTimeMillis()
The invocation is as follows:
NumberRandom nbr = new NumberRandom();
-
NumberRandom
public NumberRandom(long seed) Creates a new pseudo-random number generator, using a single seed:long
.- Parameters:
seed
- initial seedThe invocation is as follows:
NumberRandom nbr = new NumberRandom(seed);
- See Also:
-
-
Method Details
-
setRandom
public void setRandom(long seed) Adjusts the seed of the pseudo-random number generator, using a single seed:long
.- Parameters:
seed
- la semilla inicialThe invocation is as follows:
nbr.setRandom(seed);
-
getRandomUnif
public double getRandomUnif()Returns adouble
uniformly distributed pseudo-random, between 0.0 and 1.0- Returns:
- value
double
The invocation is as follows:
double random = nbr.getRandomUnif();
-
getRandomRankUnif
public double getRandomRankUnif(double min, double max) Returns adouble
uniformly distributed pseudo-random with specified range.- Parameters:
min
- valuedouble
minimum specific rangemax
- valuedouble
maximum specific range- Returns:
- value
double
between specified rangeThe invocation is as follows:
double random = nbr.getRandomRankUnif(min, max);
-
getRandomRankUnif
public int getRandomRankUnif(int min, int max) Returns aint
uniformly distributed pseudo-random with specified range.- Parameters:
min
- valueint
minimum specific rangemax
- valueint
maximum specific range- Returns:
- nĂºmero
int
between specified rangeThe invocation is as follows:
int random = nbr.getRandomRankUnif(min, max);
-