uniform random points on a torus I am choosing random points on a torus by selecting two angles at random. The problem with this approach is that points closer to the "hole" are more likely to be chosen. Is there a method which will make any point equally likely to be selected?
 A: My previous answer was for a flat 2-D annulus, but a similar method works for the surface of a torus.
Suppose the torus has a distance $R$ from the centre of the tube to the centre of the torus and a distance $r$ from the centre of the tube to the surface of the tube with $r \le R$.   Points on the surface can be specified by random angles $(\Theta, \Phi)$ chosen suitably
$\Phi$ as the angle round the torus from the origin can be chosen uniformly on $[0,2\pi)$, i.e. with density $$f(\phi) = \frac{1}{2 \pi} \text{ for } 0 \le \phi \lt 2\pi.$$  But $\Theta$ as the angle round the circular cross-section of the tube (let's say measured from pointing away from the origin) is more complicated
$\Theta$ could have a density $f(\theta)$ proportional to $2 \pi\, r(R+r \cos \theta)$. If $\Theta$  must be between $0$ and $2\pi$ then this makes $$f(\theta) = \frac{R+r\cos \theta}{2 \pi  R} \text{ for } 0 \le \theta \lt 2\pi.$$ 
Unfortunately the cumulative distribution function for $\Theta$ does not have a closed-form inverse, but you can still choose values from this density, for example by using rejection sampling:


*

*In practice, choose $U,V,W$ uniformly and independently on $[0,1]$

*Let $\Theta = 2\pi U$ and $\Phi = 2\pi V$

*If $\displaystyle W \le \frac{R+r\cos \Theta}{R+r}$ then your point is $\left((R +r \cos \Theta) \cos \Phi, (R + r \cos \Theta) \sin \Phi,  r \sin \Theta \right)$, but if $\displaystyle W \gt \frac{R+r\cos \Theta}{R+r}$ then start again by choosing new $U,V,W$ 


Note in the final point, you are more likely to reject a selection when $\Theta \approx \pi$ then when it is about $0$ or $2\pi$. This corresponds to your legitimate concern that points"nearer the hole" might otherwise be over represented 
A: This initial answer was for a flat 2-D annulus.  For the surface of a 3-D torus, see my other answer
If the distance from the origin is $R$, then $R$ could have a density $f(x)$ proportional to $2\pi x$ to give a uniform distribution on the annulus when combined with the uniformly distributed angle
If $R$ has to be between $r_{\min}$ and $r_{\max}$ then this means $f(x)=\dfrac{2x}{r_{\max}^2 - r_{\min} ^2}$ for $r_{\min} \le x \le r_{\max}$
In practice, choose $U$ uniformly on $[0,1]$ and let $R =\sqrt{U r_{\max}^2+(1-U)r_{\min} ^2}$ as the inverse of the cumulative distribution function
