Boost random::discrete_distribution How to change weights once constructed?

南楼画角 提交于 2019-12-10 18:57:27

问题


Ok, it is possible to give weights/probabilities in boost::random::discrete_distribution.

e.g.

double probabilities[] = { 0.5, 0.1, 0.1, 0.1, 0.1, 0.1 };

boost::random::discrete_distribution<> dist(probabilities);

Question: Once the object dist is constructed

(1)How to change one of the weights e.g. 0.5 to 0.3?

(2) How to reassign all the weights at once?


回答1:


Create a new distribution object and use that instead.



来源:https://stackoverflow.com/questions/8925545/boost-randomdiscrete-distribution-how-to-change-weights-once-constructed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!