【问题标题】:standard multivariate normal random vector using Boost::random使用 Boost::random 的标准多元正态随机向量
【发布时间】:2011-07-12 16:32:50
【问题描述】:

我想在 2D 表面上生成随机点, 分布在 x0、y0 坐标周围。

我知道我需要生成的称为“标准多元法线随机向量”,但我不知道如何在 C++ 中生成,例如使用 Boost::random 库.

我知道有一个生成这个的算法,称为Box–Muller transform,但我认为这一定已经在 Boost 中正确实现了。

是否有任何简单的方法可以使用 Boost::random 生成多元正态分布?

【问题讨论】:

    标签: c++ boost random geometry boost-random


    【解决方案1】:

    It seems to be:

    // deterministic Box-Muller method, uses trigonometric functions
    template<class RealType = double>
    class normal_distribution
    {
    

    但 Box-Muller 不是 2D 的。要获得 2D 版本,您真正需要做的就是获取生成的两个随机数并将它们添加到 x0, y0 坐标中。

    【讨论】:

    • 确实,n 维正态分布在其每个分量中都是正态分布。写出密度函数,您会看到它是一维密度函数的乘积。另外,如果有的话,请使用 C++0x 的 &lt;random&gt; ;-)
    猜你喜欢
    • 2014-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    • 1970-01-01
    • 2012-02-03
    • 1970-01-01
    相关资源
    最近更新 更多