python - How to generate random points in a circular distribution -


i wondering how generate random numbers appear in circular distribution.

i able generate random points in rectangular distribution such points generated within square of (0 <= x < 1000, 0 <= y < 1000):

how go upon generate points within circle such that:

(x−500)^2 + (y−500)^2 < 250000 ?

first answer: easy solution check see if result satisfies equation before proceeding.

generate x, y (there ways randomize select range)

check if ((x−500)^2 + (y−500)^2 < 250000) true if not, regenerate.

the downside inefficiency.

second answer:

or, similar riemann sums approximating integrals. approximate circle dividing many rectangles. (the more rectangles, more accurate), , use rectangle algorithm each rectangle within circle.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -