TJ Michael
TJ Michael

Reputation: 165

2d normal distribution c++

Edit: 4 Years later

In case anyone sumbles over here with a similar issue, no I never managed to resolve this problem to my satisfaction.

If you're having problems understanding what the issue had been, it had to do with my fear that there would be a similar distortion to generating a normal distribution of points around a center on a 2d plane using polar coordinates, to the distortion that is encountered when generating a uniform distribution of points in a circle around a point using polar coordinates. See here for the distortion I was reffering to.

For me the solution was just to disscuss with my client what exactly they wanted, and for them it was more important to ensure that the distances were correct then to make sure the distribution was correct radially, which given the deadline we were on at the time meant that was the end of it.


Original Post Follows:

So, my math knowledge is limited to a 3 year old high-school diploma, so I guess that this question's been answered before, but not in terms I can understand.

I've been asked to take an algorithm we use at our company, which previously generated uniformly distributed 2d points within a circle, with one that generates points within a normal distribution from a central point.

Previously I'd been using this method to calculate the x and y values of a point when it was a uniform distribution, with boost being my stand in for C#'s random generation algorithms.

I'd really appreciate any help here, preferably using boost (getting new external libs approved for use here is a pain), as I said, my math skills are pretty horrendous, so even if someone could point me in the direction of some other post about this issue, with some layman's terms to get me situated there, that would be great.

Upvotes: 0

Views: 1499

Answers (1)

sehe
sehe

Reputation: 392893

From the problem statement I'd intuitively go with normal distributions for both X and Y.

But since the comment threads seems to suggest that this is not what was intended - let me guess what was intended:

Perhaps you are looking for a points with distances to the centre that form a normal distribution.

In that case, view the problem in vector form:

  • using a single normal distribution for the distance distribution
  • using a uniform distribution to select the angle [0, 360) deg

Now it's garden variety trigonometry to calculate the target point from center + vector

Upvotes: 3

Related Questions