Reputation: 13966
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?
Upvotes: 2
Views: 1249
Reputation: 8108
// 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.
Upvotes: 3