• Portfolio and blog of sydneyzh.

# Uniform sampling from a disk

To use a pair of canonical random variables $(\varepsilon_1, \varepsilon_2)$ to sample uniformly from the disk of radius $\mathit{ R }$, the CDF function inversion method can be applied.

The first step is to calculate the normalization constant $\mathit{ C }$ of the probability density distribution function under the polar coordinate measure $(\phi, \mathit{r})$ using PDF's characteristic:

$$C\int_0^\mathit{R}\int_0^{2\pi}r\mathrm{d}r\mathrm{d}\phi = 1,$$

which gives

$$C = \frac{1}{\pi R^2}.$$

The analytic form of cumulative probability distribution function is therefore

$$F(r_0, \phi_0) = C\int_0^{r_0}\int_0^{\phi_0} r\mathrm{d}r\mathrm{d}\phi = \frac{\phi_0 r_0^2}{2 \pi R^2}.$$

Given that $\phi$ and $\mathit{r}$ are separable, $F$ can be represented by

$$\frac{\phi}{2\pi}\frac{r^2}{R^2} = F_1(\phi)F_2(r).$$

Their inverse functions

$$F_1^{-1} = 2\pi \varepsilon_1 = \phi \ \text{ and } \ F_2^{-1} = R \sqrt{\varepsilon_2} = r$$

can be used with the canonical pair $(\varepsilon_1, \varepsilon_2)$ to perform uniform sampling.

A visualization of the result: