Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 1.35 KB

README.md

File metadata and controls

23 lines (15 loc) · 1.35 KB

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

alt text

The benchmark visualization is done with http://jmh.morethan.io/