eu.gressly.hw.math.random
public interface WeightedRandomCategories
wghts = new double [] {20, 50, 30, 20};
WalkerCategories wc = new WalkerCategories(wghts);
int cat = wc.getWeightedCategory(Math.random());
// cat will be 0, 1, 2, 3 with probabilities 20:50:30:20
Method Summary | |
---|---|
int | getWeightedCategory(double uniform01)
Returns the number [0 .. n-1] of a category.
|
Parameters: uniform01 specifies a uniform distributed random number between 0 (inkl.) and 1 (exkl.)
Returns: Category number 0 .. n-1