Uniform Distribution in a Ring Area

This post aims to provide an efficient method of generating uniformly distributed coordinates in a given ring area.

Without loss of generality, the ring area is illustrated in the figure below. The inner and outer radii are R1R_1 and R2R_2, respectively, R1<R2R_1 < R_2. The corresponding angular scope starts from Θ1\Theta_1 and ends at Θ2\Theta_2, Θ1<Θ2\Theta_1 < \Theta_2.

./ring.png

In polar coordinate system, the joint probability density function (PDF) of the radius and angle can be written as

fR,Θ(r,θ)=2r(Θ2−Θ1)(R22−R12),\begin{aligned}f_{R, \Theta}(r, \theta) = \frac{2r}{(\Theta_2 - \Theta_1)(R_2^2 - R_1^2)},\end{aligned}

where θ∈[Θ1,Θ2]\theta\in[\Theta_1, \Theta_2], r∈[R1,R2]r\in[R_1, R_2].

Then, the PDFs of the radius and angle can be expressed as

fR(r)=2rR22−R12,r∈[R1,R2];fΘ(θ)=1Θ2−Θ1,θ∈[Θ1,Θ2].\begin{aligned}f_R(r) &= \frac{2r}{R_2^2 - R_1^2}, \quad r\in[R_1, R_2];\\f_{\Theta}(\theta) &= \frac{1}{\Theta_2 - \Theta_1}, \quad \theta\in[\Theta_1, \Theta_2].\end{aligned}

Consequently, the target coordinate can be generated as follows

  • A desired radius can be got by XR12+(1−X)R22\sqrt{XR_1^2 + (1-X)R_2^2}, where X∼U(0,1)X \sim \mathcal{U}(0, 1).
  • A desired angle is uniformly distributed within the range (Θ1,Θ2)(\Theta_1, \Theta_2), i.e., Θ∼U(Θ1,Θ2)\Theta \sim \mathcal{U}(\Theta_1, \Theta_2).