WeightedRandomDistribution:加权随机分布的 ALIAS 方法的实现

时间:2021-07-06 12:59:26
【文件属性】:
文件名称:WeightedRandomDistribution:加权随机分布的 ALIAS 方法的实现
文件大小:7KB
文件格式:ZIP
更新时间:2021-07-06 12:59:26
Scala 加权随机分布 加权随机分布的 ALIAS 方法的 Scala 实现。 加权随机分布允许您从值列表中随机选择一个元素,其中每个值都有指定的权重。 ALIAS 方法是一种在元素选择中实现恒定时间性能的算法。 请参阅以深入了解该主题。 例子 假设您想在红色、绿色和蓝色之间随机选择一种颜色,这样选择红色的次数为 50%,绿色为 30%,蓝色为 20%。 import nicmart . _ val weightedValues = List ( WeightedValue ( " red " , 5 ), WeightedValue ( " green " , 3 ), WeightedValue ( " blue " , 2 )) val distribution = new WeightedRandomDistribution (weightedValues) 然后,您可以将分布作
【文件预览】:
WeightedRandomDistribution-master
----project()
--------build.properties(132B)
----src()
--------test()
--------main()
----LICENSE(552B)
----build.sbt(343B)
----README.md(984B)
----.gitignore(95B)

网友评论