Uniform ball sampling by Brownian stopping (source code)

= Uniform ball sampling by Brownian stopping
{title2=$W_{\tau_R}\sim\operatorname{Unif}(B(0,r))$}

For standard <Brownian motion> started at zero, choose an <independent> radius $R$ with $\mathbb P(R\leq s)=(s/r)^n$, $0\leq s\leq r$, and stop on first reaching that radius. <Rotational invariance of Brownian motion> makes the conditional exit position uniform on each sphere. Mixing with radius density $ns^{n-1}/r^n$ gives the uniform <probability distribution> on the ball. In dimension one, the conditional sign has probabilities $1/2,1/2$. The stopped point samples volume measure even though each conditional exit law is supported on a boundary.