Processing math: 100%

Friday, 9 November 2012

Uniformly Distributed Random Points Inside a Circular Ring

I will continue my series of posts on generating uniformly distributed points within different shapes by considering a circular ring (a.k.a. annulus or doughnut). Just like my previous post we have the joint probability density function (PDF) of the x and y coordinate of the random points as:

fX,Y(x,y)={1A=1π(R2c2R2c1)R2c1x2+y2R2c20otherwise,

where Rc2 is the radius of the outer circle and Rc1 is the radius of the inner circle, and Rc1<Rc2

Using a similar technique as in the previous post we have:
fR,Θ(r,θ)=12π×2rR2c2R2c1=fΘ(θ)fR(r)

where
fΘ(θ)=12π for 0θ2π

and
fR(r)=2rR2c2R2c1 for Rc1rRc2.

  
Therefore, Θ is uniformly distributed between 0 and 2π. The random variable R can be generated by first calculating its cumulative distribution function as
FR(r)=rRc12αR2c2R2c1dα=r2R2c1R2c2R2c1,

and then using a uniformly distributed random variable U over the interval [0,1] to get
U=R2R2c1R2c2R2c1R=(R2c2R2c1)U+R2c1.


The following MATLAB code generates 1000 random numbers inside a circular ring with outer radius 20, and inner radius 10 centered at 30, 40.
 
%********************************************** 
n = 10000;
Rc2 = 20;
Rc1 = 10;
Xc = -30;
Yc = -40;

theta = rand(1,n)*(2*pi);

r = sqrt((Rc2^2-Rc1^2)*rand(1,n)+Rc1^2);
x = Xc + r.*cos(theta);
y = Yc + r.*sin(theta);

plot(x,y,'.'); axis square

%********************************************** 


4 comments:

  1. Hi there,

    Your post really helps me. Did you publish this somewhere ? I am trying to use this in my paper and try to find one of your paper as a citation.

    ReplyDelete
  2. Thanks a lot.

    ReplyDelete
  3. Hello Nariman,
    I'm trying to use this information in my thesis. I'm wondering about how to cite this in my thesis?
    Thanks,

    ReplyDelete