开发者

standard multivariate normal random vector using Boost::random

I would like to generate random points on a 2D surface, distributed around a x0, y0 coordinate.

I understand that what I need to generate is called "standard multivariate normal random vector", but I don't know how to do it in C++, for example using 开发者_开发技巧the Boost::random library.

I know there is an algorith for generating this, called Box–Muller transform but I would think that this must have already been implemented properly in Boost.

Is there any simple way to generate multivariate normal distribution, using Boost::random?


It seems to be:

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

But Box-Muller isn't 2D. All you really have to do to get the 2D version is to take the two random numbers generated and add them to the x0, y0 coordinates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜