techniques.utils
Class Random
java.lang.Object
|
+--techniques.utils.Random
- public class Random
- extends Object
Method Summary |
static boolean |
coinFlip()
Returns true with probability 0.5. |
static int |
random(int max)
Returns uniformly a number between 0 and max-1 (inclusive) |
static int |
sampleCompleteProbDist(double[] prob)
Samples from input based on given complete probability
distribution (prob. |
static int |
samplePartialProbDist(double[] prob)
Samples from input based on given probability distribution. |
Random
public Random()
coinFlip
public static boolean coinFlip()
- Returns true with probability 0.5.
random
public static int random(int max)
- Returns uniformly a number between 0 and max-1 (inclusive)
sampleCompleteProbDist
public static int sampleCompleteProbDist(double[] prob)
- Samples from input based on given complete probability
distribution (prob. sum to 1).
- Parameters:
prob
- - array of probabilities (summing to 1)- Returns:
- - value between 0 and prob.length (inclusive)
based on uniform sampling of input prob
samplePartialProbDist
public static int samplePartialProbDist(double[] prob)
- Samples from input based on given probability distribution. Is more flexible
than sampleCompleteProbDist since the prob. dist. don't need to sum to 1,
however, sampleCompleteProbDist includes an implicit error check.
- Parameters:
prob
- - array of probabilities- Returns:
- - value between 0 and prob.length (inclusive)
based on uniform sampling of input prob