Package org.dreambot.api.methods
Class Randoms
- java.lang.Object
-
- org.dreambot.api.methods.Randoms
-
public final class Randoms extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Randoms()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanchance(int target)Checks if the given {@param target} is less than or equal to a random value between 0(inclusive) and 100 (exclusive)static booleanchance(int target, int overall)Checks if the given {@param target} is less than or equal to a random value between 0(inclusive) and {@param overall}(exclusive) Method just returns Calculations.random(overall) <= targetstatic java.util.RandomgetSecureRandom()static doublegetSeededDouble(java.lang.String seed, double min, double max)static intgetSeededInt(java.lang.String seed, int min, int max)static doublenextGammaRandom(int shape, int scale)Generates a random value from theGammaDistributionstatic doublenextGaussianRandom(double mean, double sigma)Generates a random value from the Normal (or Gaussian) distribution with specified mean and standard deviation.static doublenextHypergeometricRandom(int populationSize, int numberOfSuccesses, int sampleSize)Generates a random value from theHypergeometricDistribution.static doublenextLogNormalDistributionRandom(double scale, double shape)Generates a lognormal distribution using the provided parameters with an inverse absolute accuracy of 1e-9 and uses a Well19937c number generator to return a samplestatic doublerandom(double lower, double upper)Generates a uniformly distributed random value from the open interval (lower, upper) (i.e., endpoints excluded).static intrandom(int high)Returns a number between 0 (inclusive) and high (exclusive)static intrandom(int min, int max)Gets a random number between min (inclusive) and max (exclusive)static longrandom(long min, long max)Gets a random number between min (inclusive) and max (exclusive)static voidsetSeed(long seed)static voidsetSeed(java.lang.String salt)
-
-
-
Method Detail
-
random
public static int random(int high)
Returns a number between 0 (inclusive) and high (exclusive)- Parameters:
high- upper bounds of random number (exclusive)- Returns:
- int between 0(inclusive) and max(exclusive)
-
random
public static int random(int min, int max)Gets a random number between min (inclusive) and max (exclusive)- Parameters:
min- minimum numbermax- maximum number- Returns:
- int between min(inclusive) and max(exclusive)
-
nextLogNormalDistributionRandom
public static double nextLogNormalDistributionRandom(double scale, double shape) throws org.apache.commons.math3.exception.NotStrictlyPositiveExceptionGenerates a lognormal distribution using the provided parameters with an inverse absolute accuracy of 1e-9 and uses a Well19937c number generator to return a sample- Parameters:
scale- scale parameter (median of the distribution)shape- shape parameter (std. dev. of the log of the distribution)- Returns:
- a sample from the distribution
- Throws:
org.apache.commons.math3.exception.NotStrictlyPositiveException- if shape is less than or equal to 0
-
random
public static double random(double lower, double upper)Generates a uniformly distributed random value from the open interval (lower, upper) (i.e., endpoints excluded).- Parameters:
lower- the exclusive lower bound of the supportupper- the exclusive upper bound of the support- Returns:
- a uniformly distributed random value between lower and upper (exclusive)
- Throws:
org.apache.commons.math3.exception.NumberIsTooLargeException- if lower is greater than upper.org.apache.commons.math3.exception.NotFiniteNumberException- if one of the bounds is infiniteorg.apache.commons.math3.exception.NotANumberException- if one of the bounds is NaN
-
random
public static long random(long min, long max)Gets a random number between min (inclusive) and max (exclusive)- Parameters:
min- minimum numbermax- maximum number- Returns:
- Long between min(inclusive) and max(exclusive)
-
nextGaussianRandom
public static double nextGaussianRandom(double mean, double sigma)Generates a random value from the Normal (or Gaussian) distribution with specified mean and standard deviation.- Parameters:
mean- the standard mean of the distributionsigma- the standard deviation of the distribution- Returns:
- a random value following the specified Gaussian distribution.
- Throws:
org.apache.commons.math3.exception.NotStrictlyPositiveException- if sigma less or equal to 0.
-
nextHypergeometricRandom
public static double nextHypergeometricRandom(int populationSize, int numberOfSuccesses, int sampleSize)Generates a random value from theHypergeometricDistribution.- Parameters:
populationSize- the population size of the Hypergeometric distribution.numberOfSuccesses- number of successes in the population of the Hypergeometric distribution.sampleSize- the sample size of the Hypergeometric distribution.- Returns:
- random value sampled from the Hypergeometric(populationSize, numberOfSuccesses, sampleSize) distribution.
- Throws:
org.apache.commons.math3.exception.NotStrictlyPositiveException- if shape less or equal to 0 or scale less or equal to 0.
-
nextGammaRandom
public static double nextGammaRandom(int shape, int scale)Generates a random value from theGammaDistribution- Parameters:
shape- the median of the Gamma distributionscale- the scale parameter of the Gamma distribution- Returns:
- random value sampled from the Gamma(shape, scale) distribution.
- Throws:
org.apache.commons.math3.exception.NotStrictlyPositiveException- if shape less or equal to 0 or scale less or equal to 0.
-
setSeed
public static void setSeed(long seed)
-
setSeed
public static void setSeed(java.lang.String salt)
-
getSecureRandom
public static java.util.Random getSecureRandom()
-
chance
public static boolean chance(int target, int overall)Checks if the given {@param target} is less than or equal to a random value between 0(inclusive) and {@param overall}(exclusive) Method just returns Calculations.random(overall) <= target- Parameters:
target- target value to checkoverall- overall value for a 0 to overall random check- Returns:
- true if {@param target} is less than or equal to
random(int)with {@param overall} passed to random
-
chance
public static boolean chance(int target)
Checks if the given {@param target} is less than or equal to a random value between 0(inclusive) and 100 (exclusive)- Parameters:
target- target value to check for- Returns:
- true if {@param target} is less than or equal to a random value between 0(inclusive) and 100 (exclusive)
-
getSeededInt
public static int getSeededInt(java.lang.String seed, int min, int max)
-
getSeededDouble
public static double getSeededDouble(java.lang.String seed, double min, double max)
-
-