How to sample from a probability distribution on the unit sphere?

518 Views Asked by At

I'm dealing with the following problem:

"Given a set of $N$ points on the unit sphere, sample a new set of $M$ points having the same probability distribution."

I know that the simple 1D version can be solved e.g. with the inverse transform sampling method, but I couldn't find any reference on how to tackle this 3D equivalent on the unit sphere. Does anyone have good resources or hints about this?

Thank you in advance.

3

There are 3 best solutions below

3
On
  1. Continuous Uniform Distribution. The total surface of the unit sphere is $$ S_2=\int_0^{2\pi}\int_0^{\pi}\sin\theta\,d\theta\,d\phi=4\pi\,, $$ where $\theta,\phi$ are polar angles latitude and longitude (aka meridian). Unlike on earth, the convention here is that the north pole is at $\theta=0\,.$ One could now sample the random angles $\Theta,\Phi$ such that $$ \mathbb P(\Theta\le \theta,\Phi\le\phi)=\frac{1}{4\pi}\int_0^\phi\int_0^\theta\sin t\,dt\,dp=\frac{1}{4\pi}\phi\,(1-\cos\theta)\,. $$ The joint distribution of $\Theta$ and $\Phi$ is obviously the product of the marginal distributions $$ \mathbb P(\Theta\le\theta)=\frac{1}{2}(1-\cos\theta)\quad\text{ and }\quad\mathbb P(\Phi\le\phi)=\frac{\phi}{2\pi}\,. $$ Clearly, the meridian $\Phi$ has a uniform distribution on $[0,2\pi]$ and the latitude $\Theta$ can be sampled by drawing a uniform $U\in{\cal U}(0,1)$ and inverting the marginal distribution of $\Theta:$ $$ \Theta=\arccos(1-2U)\,. $$

  2. Discrete Uniform Distribution. A finite number of $N$ points can be put relatively homogeneously onto the sphere when the differences in their longitudes $\phi_i$ and latitudes $\theta_i$ satisfy $$ \phi_i-\phi_{i-1}=\frac{2\sqrt{\pi}}{\sqrt{N}\sin\theta_i}\,,\quad\theta_i-\theta_{i-1}=\frac{2\sqrt{\pi}}{\sqrt{N}}\,,\quad i=1,...,N\,. $$ Clearly, \begin{align} &\mathbb P(\theta_{i-1}\le\Theta\le\theta_i,\phi_{i-1}\le\Phi\le\phi_i) \\[3mm] &=\mathbb P(\Theta\le\theta_i,\Phi\le\phi_i) -\mathbb P(\Theta\le\theta_i,\Phi\le\phi_{i-1})\\[3mm] &\quad-\mathbb P(\Theta\le\theta_{i-1},\Phi\le\phi_i) +\mathbb P(\Theta\le\theta_{i-1},\Phi\le \phi_{i-1})\\[3mm] &=\frac{\phi_i(1-\cos\theta_i)-\phi_{i-1}(1-\cos\theta_i)-\phi_i(1-\cos\theta_{i-1})+\phi_{i-1}(1-\cos\theta_{i-1})}{4\pi}\\ &=\frac{(\cos\theta_{i-1}-\cos\theta_i)(\phi_i-\phi_{i-1})}{4\pi}\,. \end{align} For large $N$ the difference $\theta_i-\theta_{i-1}$ small so that this probability is approximately equal to \begin{align} \frac{\sin\theta_i(\theta_i-\theta_{i-1})(\phi_i-\phi_{i-1})}{4\pi}=\frac{1}{N} \end{align} which is equal for all cells $[\phi_{i-1},\phi_i]\times[\theta_{i-1},\theta_i]\,.$

3
On

You are given $N$ points on a sphere, $X=\{x_1,\dots,x_N\}$. In order to generate a new point $y$ with a similar distribution to $X$,

  • Choose $x\in X$ uniformly at random.

  • Choose an angle $\theta\in [0,2\pi)$ uniformly at random.

  • Choose a positive number $r$ using some continuous distribution on $[0,\pi)$. The distribution should be tightly clustered near $0$. For example, the continuous uniform distribution on $[0,\pi/20]$ would work.

  • Place a vector at $x$, pointing to the north pole. Rotate that vector by $\theta$, clockwise. Walk $r$ units along the direction of the rotated vector. Where you end up is the new point $y$.

Repeat this process $M$ times to generate $M$ points. Note that every point $y$ will tend to cluster where $X$ clusters, but will never be exactly equal to any of the points in $X$.

0
On

You should consider using a kernel density estimator to estimate the pdf and then sample from that estimated pdf as in the answer from Mike Earnest.

Although kernel density estimation with Gaussian kernels is widely used for distributions in $R^{n}$ and discussed in many textbooks, you need a version customized to work on the sphere. The von-Mises-Fisher distribution is often used instead of a Gaussian kernel.

A google search on "spherical kernel density estimation" quickly leads to many research papers on the topic and at least one software package written in Python.

See for example:

Hall, Peter, G. S. Watson, and Javier Cabrera. "Kernel density estimation with spherical data." Biometrika 74, no. 4 (1987): 751-762.

Pelletier, Bruno. "Kernel density estimation on Riemannian manifolds." Statistics & probability letters 73, no. 3 (2005): 297-304.

Gray, Alexander G., and Andrew W. Moore. "Nonparametric density estimation: Toward computational tractability." In Proceedings of the 2003 SIAM International Conference on Data Mining, pp. 203-211. Society for Industrial and Applied Mathematics, 2003.

Software:

https://github.com/williamjameshandley/spherical_kde