Quantcast
Channel: Active questions tagged real-analysis - Mathematics Stack Exchange
Viewing all articles
Browse latest Browse all 9155

Confusion on defining uniform distribution on hypersphere and its sampling problem

$
0
0

Fix a dimension $d$. Write $S^{d-1}$ for the surface of a hypersphere in $\mathbb{R}^d$, namely set of all $x = (x_1, \ldots, x_d) \in \mathbb{R}^d$ such that $|x|^2 = x_1^2 + \cdots + x_d^2 = 1$. I would like a post to finish the discussion once and for all about :

  1. What most commonly do people mean when they "sample uniformly" on $S^{d-1}$, especially in an "applied" context (That is, I assume people talk about this subject because they really need to code and generate observations to be used in some algorithms)?
  2. Assume that we can generate standard uniform distribution. Compactible with question 1, what are some of the easiest, mathematically justified, ways to do it?

This question has been heavily discussed. See for example :

  1. https://stats.stackexchange.com/questions/331253/draw-n-dimensional-uniform-sample-from-a-unit-n-1-sphere-defined-by-n-1-dime?noredirect=1&lq=1
  2. How to write a proper definition of the uniform distribution on unit sphere?
  3. https://mathworld.wolfram.com/HyperspherePointPicking.html
  4. https://stats.stackexchange.com/questions/77440/sampling-uniformly-from-n-sphere-using-spherical-coordinates
  5. https://mathoverflow.net/questions/24688/efficiently-sampling-points-uniformly-from-the-surface-of-an-n-sphere
  6. https://projecteuclid.org/journals/annals-of-mathematical-statistics/volume-43/issue-2/Choosing-a-Point-from-the-Surface-of-a-Sphere/10.1214/aoms/1177692644.full
  7. Even the wikipedia has a little section about it : https://en.wikipedia.org/wiki/N-sphere.

The trouble I am getting is that, question 2 really seems to have a lot of solutions, but most are not preceded by any discussion on question 1 whatsoever (and the solutions is often not very mathematically justified either). Even published papers do not seem to be very clear about this issue.

In my opinion, the uniform distribution for a finite measure space $(X, F_X, \nu)$ where $\nu(X) > 0$ and every singleton is measurable should be the probability measure $P$ such that its density $f$ with respect to $\nu$ is constant. For example, the non-disputed $d=1$ case satisfies $X = \{1,-1\}$, $\nu$ equals the counting measure, and $f(x) \equiv \frac{1}{2}$ for every $x$. The uniform distribution on an interval has $f$ constantly equal to inverse of the length with $\nu$ being the Lebesgue measure. (Although, sometimes, when the space is $\sigma$-finite like $X = \mathbb{R}$ and $\nu$ equals the Lebesgue measure, there are cases where we call $f\equiv 1$ uniform as well. I guess this does not apply to this problem. If $\nu(X)=0$, the uniform distribution should be left undefined.)

Therefore, the problem should lie on what is $\nu$ when $X = S^{d-1}$. The most popular choice still seems to be the surface measure (defined say on Folland's Analysis theorem 2.49). After all, this is the measure that is always used for polar coordinates in $\mathbb{R}^d$. In this case:

\begin{equation*}\nu(S^{d-1}) = \frac{2 \pi^{\frac{d}{2}}}{\Gamma(\frac{d}{2})}\end{equation*}

The uniform distribution would be :

\begin{equation*}f(x) \equiv \frac{\Gamma(\frac{d}{2})}{2 \pi^{\frac{d}{2}}}\end{equation*}

This all sounds reasonable and conventional (if this is not the case, please point out).However, the several most popular solutions do not seem to be using it. Assume from now on that $d \geqslant 2$. I give some solutions I am most interested in, be them right or wrong :

  1. Use spherical coordinates.

\begin{align*}x_1 &= \cos(\phi_1)\,,\\x_2 &= \sin(\phi_1)\cos(\phi_2)\,,\\&\quad\quad\vdots\\x_{d-1} &= \sin(\phi_1)\cdots\sin(\phi_{d-2})\cos(\phi_{d-1})\,,\\x_d&=\sin(\phi_1)\cdots\sin(\phi_{d-2})\sin(\phi_{d-1})\,,\\\end{align*}

Here $\phi_{d-1} \in [0,2\pi)$ and all the rest are in $[0, \pi]$. Generate $\phi_{d-1}$ from $\text{Uniform}[0,2\pi)$ and the rest from $\text{Uniform}[0,\pi]$ all independently, and use the formula above to get a sample of $x$. People seem to criticize this for $d \geqslant 3$ only (e.x https://angms.science/doc/RM/randUnitVec.pdf). If we use surface measure, this seem to be a good way?

  1. The same as in solution 1, but proceed as in the answer in the very first reference. I am not sure where that method comes from.

From the surface measure, one might get the solution 1 or 2 I just wrote about, although I have difficulty filling in the details. But if the problem is already solved with 1 or 2, why so many methods and discussions?

  1. Generate $Y_1, \ldots, Y_d$ independent identically distributed from $N(0,1)$, and put, for each $i$ :

\begin{equation*}X_i = \frac{Y_i}{\sqrt{Y_1^2 + \cdots + Y_d^2}}\end{equation*}

Then $X = (X_1, \ldots, X_d)$ will be a uniform sample on $S^{d-1}$. The symmetry seems intuitive, but I do not know how to justify it or whether it is compactible with the surface measure definition.

I am even more lost at other methods.


Thank you for all your answers.

Conclusion :

The default uniform distribution on $S^{d-1}$ is the https://en.wikipedia.org/wiki/Spherical_measure . Despite many names along with the implied different constructions ( for instance normalized surface measure, normalized $d-1$ dimensional Hausdorff measure or Haar measure on a hypersphere ), they are one and the same, because there is only one unique probability measure among all measures on $S^{d-1}$ that is invariant under action of $d \times d$ orthogonal group, see for instance Uniqueness of the uniform spherical distribution . Pursuing the invariance direction, solution 3 provides a probability measure also invariant under orthogonal group, and is thus immediately seen correct by uniqueness. By pursuing along the direction of generating normalized surface measure, solution 2 does the correct computation and is acceptable. Solution 1 forgets about multiplying Jacobian and is incorrect when $d \geqslant 3$.


Viewing all articles
Browse latest Browse all 9155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>