Skip to content

Multiple benchmerked implementations of weighted lottery

License

Notifications You must be signed in to change notification settings

ahadadi/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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 55.6%
  • Java 44.4%