I want to sample uniformly from the area bounded by $y=0$, $x=3$, and $y=\sqrt{x}$:
[![enter image description here][1]][1]

If I draw $x$ from $U[0, 3]$ and $y$ from $U[0, \sqrt{x}]$, the density will be higher in the bottom left corner:
[![enter image description here][2]][2]

I tried to fix this by making the number of points on a region bounded by $x=a \in [0, 3]$ on the right, the square root curve, and the $x$-axis proportional to its area (relative to that of the entire figure).

So, the total area should be: $$\int_{0}^{3}\sqrt{x}dx = \frac{2}{3}x^{\frac{3}{2}}\bigg\rvert_{0}^{3}=2\sqrt{3}$$

The area bounded by $x=a$ on the right is $\frac{2}{3}a^{\frac{3}{2}}$, so the pdf of $x$ should be proportional to the ratio, i.e.:
$$
pdf(x) = C \times \frac{\frac{2}{3}a^{\frac{3}{2}}}{2\sqrt{3}} = \frac{C}{3\sqrt{3}}a^{\frac{3}{2}}
$$

The corresponding CDF is then:

$$
CDF(x) = \int_{0}^{x} pdf(u)du = \int_{0}^{x} \frac{C}{3\sqrt{3}}u^{\frac{3}{2}}du = \frac{C}{3\sqrt{3}} \times \frac{2}{5} u^{\frac{5}{2}} \bigg\rvert_{0}^{x}
$$

$$
CDF(x) = \frac{C}{3\sqrt{3}} \times \frac{2}{5} x^{\frac{5}{2}} = \frac{2C}{5\times3\sqrt{3}} x^{\frac{5}{2}}
$$

I get $C$ from the condition $CDF(3)=1$:
$$
CDF(3) = \frac{2C}{5\times3\sqrt{3}} 3^{\frac{5}{2}} = \frac{2C}{5}\times 3 = \frac{6C}{5} = 1
$$
So:
$$
C = \frac{5}{6} \implies \quad CDF(x) = \left(\frac{x}{3}\right)^{\frac{5}{2}}
$$

Therefore, I should sample $x$ by sampling a random number $r \in Uniform[0, 1]$ and solving $CDF(x)=r$ for $x$:
$$
x = 3 \times r^{\frac{2}{5}} \quad (r \in Uniform[0,1])
$$

and get $y$ by sampling from $Uniform[0, \sqrt{x}]$. However, this approach doesn't make the distribution uniform:
[![enter image description here][3]][3]
The sampled points are now concentrated away from the bottom left corner.

Can someone help me? :)

  [1]: https://i.sstatic.net/Nk951.png
  [2]: https://i.sstatic.net/qXsI1.png
  [3]: https://i.sstatic.net/YLNm3.png