kotlin-statistics v1.2.1 Release Notes

Release Date: 2018-12-27 // over 1 year ago
  • 0️⃣ Made some fixes to the binByComparable() implementation so ends are not exclusive by default.

Previous changes from v1.1.3

  • 🚀 This release contains some practical features for randomness and weighted probabilities.

    Kotlin-Statistics now has a few helpful extensions to randomly sample elements from an Iterable<T> or Sequence<T>.

    • randomFirst() - Selects one random element but throws an error if no elements are found.
    • randomFirstOrNull() - Selects one random element but returns null if no elements are found.
    • random(n: Int) - Selects n random elements.
    • randomDistinct(n: Int) - Select n distinct random elements.

    Also available are WeightedCoin and WeightedDice utilities which can be helpful to assign probabilities to discrete true/false or T outcomes. This can be helpful for games, stochastic programming, simulation, and optimization.

    enum class Move { ATTACK, DEFEND, HEAL, RETREAT}fun main(args: Array\<String\>) { val gameDice = WeightedDice( Move.ATTACK to .60, Move.DEFEND to .20, Move.HEAL to .10, Move.RETREAT to .10 ) val nextMove = gameDice.roll() println(nextMove) }