从在C离散概率分布采样++ [英] Sampling from a discrete probability distribution in C++

查看:230
本文介绍了从在C离散概率分布采样++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的C ++和缺乏访问,共同概率处理工具(即升压缺少的东西和标准库)非常惊讶。我已经做了很多其他语言的科学规划的,但标准和/或普遍存在的第三方插件总是包括全方位的概率工具。一位朋友发单了加速是相当的无处不在附加的C ++,但我读了Boost文档,甚至它似乎有什么,我会考虑非常基本的内置插件的缺乏。

I am new to C++ and extremely surprised by the lack of accessible, common probability manipulation tools (i.e. the lack of things in Boost and the standard library). I've done a lot of scientific programming in other languages, but the standard and/or ubiquitious third party add-ons always include a full range of probability tools. A friend billed up Boost to be the equivalent ubiquitous add-on for C++, but as I read the Boost documentation, even it seems to have a dearth of what I would consider extremely elementary built-ins.

我不能找到一个内置在需要某种离散概率阵列,并产生根据这些概率选择的索引。我当然可以写我自己的功能,但我只是想检查我是否缺少一个标准的方式来做到这一点。

I cannot find a built in that takes some sort of array of discrete probabilities and produces an index chosen according to those probabilities. I can of course write my own function for this, but I just wanted to check whether I am missing a standard way to do this.

具有这样的低级别写我自己的函数是一件坏事,我的感觉,但我写了一个更大的项目,是所有在C ++中一个新的仿真模块。我通常去到战术将它写在Python和Python的链接到C ++,但由于其他几人将不得不一旦我完成它,他们都不知道Python来管理这个code,I认为这将是更谨慎地交付给他们所有的C ++。

Having to write my own functions at such a low-level is a bad thing, I feel, but I am writing a new simulation module for a larger project that is all in C++. My usual go-to tactic would be to write it in Python and link the Python to the C++, but because several other people are going to have to manage this code once I finish it, and none of them know Python, I think it would be more prudent to deliver it to them all in C++.

更一般地,什么人做的C ++之类的东西从标准抽样分布,尤其是一些基本的一个多变量正态分布?

More generally, what do people do in C++ for things like sampling from standard distributions, in particular something as basic as a multi-variate normal distribution?

推荐答案

(从评论感动。)

你看 Boost.Math.StatisticalDistributions ?具体来说,其离散概率分布的?

Did you look at Boost.Math.StatisticalDistributions? Specifically, its Discrete Probability Distributions?

升压是不是一个图书馆,这是一个的的库,所以有时很难找到你正在寻找什么&ndash的;但是,这并不意味着它不存在。 ; - ]

Boost is not a library, it's a collection of libraries, so it can sometimes be difficult to find exactly what you're looking for – but that doesn't mean it isn't there. ;-]

这篇关于从在C离散概率分布采样++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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