升压随机:: discrete_distribution如何改变权重一旦构造? [英] Boost random::discrete_distribution How to change weights once constructed?

查看:254
本文介绍了升压随机:: discrete_distribution如何改变权重一旦构造?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这有可能给予的权重/概率在boost ::随机:: discrete_distribution。

例如

双重概率[] = {
    0.5,0.1,0.1,0.1,0.1,0.1
};

的boost ::随机:: discrete_distribution<>的 DIST 的(概率);

问题:一旦对象的 DIST 的构造


  

(1)如何改变的权重的一个例如0.5〜0.3?


  
  

(2)如何一次重新分配所有的砝码?



解决方案

创建一个新的发行对象,并使用它。

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?

解决方案

Create a new distribution object and use that instead.

这篇关于升压随机:: discrete_distribution如何改变权重一旦构造?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆