Open GregHib opened 4 years ago
import org.apache.commons.math3.distribution.EnumeratedDistribution
import org.apache.commons.math3.util.Pair
val nested = EnumeratedDistribution(
listOf(
Pair("Third", 0.5),
Pair("Fourth", 0.5)
)
)
val list = listOf<Pair<Any, Double>>(
Pair("First", 0.2),
Pair("Second", 0.4),
Pair(
nested,
0.5
),
Pair("Fifth", 0.3)
)
val distribution = EnumeratedDistribution<Any>(list)
fun main() {
repeat(10) {
var sample = distribution.sample()
while (sample is EnumeratedDistribution<*>) {
sample = sample.sample()
}
println(sample)
}
}
Pros:
Cons:
Requirements:
Drop tables are essentially simplified utility-based systems #58 so why not plan them to cover these use cases instead? If containers #76 are made functionally #92 couldn't we pass add functions as the values of a table and then just apply/transform the choice onto the container?
Further reading