2 added 68 characters in body
source | link

In my opinion, the easiest option which also generalizes to higher dimensional balls (which is not the case of spherical coordinates and even less the case of rejection sampling) is to generate random points $P$ that are products of two random variables $P = N/||N|| * U$$P = N/||N|| * U^{1/n}$ where $N$ is a Gaussian random variable (i.e. isotropic, i.e. pointing in any direction uniformly) normalized so that it lies on the sphere and $U$ which is a uniform random variable in $[0,1]$ to the power $1/n$, $n$ being the dimensionality of the data, taking care of the radius.

Et voilà!

In my opinion, the easiest option which also generalizes to higher dimensional balls (which is not the case of spherical coordinates and even less the case of rejection sampling) is to generate random points $P$ that are products of two random variables $P = N/||N|| * U$ where $N$ is a Gaussian random variable (i.e. isotropic, i.e. pointing in any direction uniformly) normalized so that it lies on the sphere and $U$ which is a uniform random variable in $[0,1]$ taking care of the radius.

Et voilà!

In my opinion, the easiest option which also generalizes to higher dimensional balls (which is not the case of spherical coordinates and even less the case of rejection sampling) is to generate random points $P$ that are products of two random variables $P = N/||N|| * U^{1/n}$ where $N$ is a Gaussian random variable (i.e. isotropic, i.e. pointing in any direction uniformly) normalized so that it lies on the sphere and $U$ which is a uniform random variable in $[0,1]$ to the power $1/n$, $n$ being the dimensionality of the data, taking care of the radius.

Et voilà!

1
source | link

In my opinion, the easiest option which also generalizes to higher dimensional balls (which is not the case of spherical coordinates and even less the case of rejection sampling) is to generate random points $P$ that are products of two random variables $P = N/||N|| * U$ where $N$ is a Gaussian random variable (i.e. isotropic, i.e. pointing in any direction uniformly) normalized so that it lies on the sphere and $U$ which is a uniform random variable in $[0,1]$ taking care of the radius.

Et voilà!