fX,Y(x,y)={1A=1π(R2c2−R2c1)R2c1≤x2+y2≤R2c20otherwise,
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π×2rR2c2−R2c1=fΘ(θ)fR(r)
where
fΘ(θ)=12π for 0≤θ≤2π
and
fR(r)=2rR2c2−R2c1 for Rc1≤r≤Rc2.
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αR2c2−R2c1dα=r2−R2c1R2c2−R2c1,
and then using a uniformly distributed random variable U over the interval [0,1] to get
U=R2−R2c1R2c2−R2c1⟹R=√(R2c2−R2c1)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
%**********************************************
Hi there,
ReplyDeleteYour 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.
Thanks a lot.
ReplyDeleteThanks lots
ReplyDeleteHello Nariman,
ReplyDeleteI'm trying to use this information in my thesis. I'm wondering about how to cite this in my thesis?
Thanks,