Skip to content

guyko/weighted-lottery

Repository files navigation

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/

About

Multiple benchmerked implementations of weighted lottery

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •