Multiple implementations of weighted lottery, in java or kotlin.
Weighted lottery deals allows to randomly select items according to given probabilities, with or without repetitions, in the following manner:
val weights = doubleArrayOf(0.15, 0.0, 0.2, 0.0, 0.65)
val lottery = SimpleWeightedLottery(weights)
(0 until k).forEach {
val index = lottery.draw()
// do something
}
For more details on weighted-lottory, follow the wiki page
All implementations are benchmarked using JMH, and can be found here
The benchmark visualization is done with http://jmh.morethan.io/