randomWeighted

fun <T> List<T>.randomWeighted(weights: List<Float>, random: Random = Random): T

Get one random element of a given List.

The probability for each element is proportional to the value of its corresponding element in the weights List.

Sources

jvm source
Link copied to clipboard