Skip to main content
QUICK REVIEW

[Paper Review] A simple algorithm for uniform sampling on the surface of a hypersphere

Stefan Schnabel, Wolfhard Janke|arXiv (Cornell University)|Apr 5, 2022
Satellite Image Processing and Photogrammetry4 citations
TL;DR

This paper presents a computationally efficient algorithm for uniform sampling on the surface of an n-dimensional hypersphere, especially effective for even dimensions. By using rejection sampling to generate unit-circle points and sorting their squared radii, the method avoids expensive trigonometric or root functions, enabling fast, high-dimensional sampling with minimal computational overhead.

ABSTRACT

We propose a simple method for uniform sampling of points on the surface of a hypersphere in arbitrarily many dimensions. By avoiding the evaluation of computationally expensive functions like logarithms, sines, cosines, or higher order roots the new method is faster than alternative techniques.

Motivation & Objective

  • To develop a simple, efficient algorithm for uniform sampling on the surface of an n-dimensional hypersphere.
  • To avoid computationally expensive operations like logarithms, sines, cosines, and higher-order roots commonly used in existing methods.
  • To generalize Marsaglia’s efficient 3D and 4D sampling techniques to arbitrary even dimensions.
  • To provide a method that remains efficient for small to moderately large n, especially when performance is critical.
  • To offer a variant that generates points uniformly within the n-ball, extending applicability to volume sampling.

Proposed method

  • Generate n/2 pairs of i.i.d. uniform random variables (a, b) in [-1, 1) and reject those where a² + b² ≥ 1, ensuring points lie within the unit disk.
  • Sort the resulting pairs by their squared radius S_i = a_i² + b_i² to form an ordered sequence S_0 = 0 ≤ S_1 ≤ ... ≤ S_{n/2}.
  • Assign coordinates using the formula X_{2i-1} = r_i * a_i and X_{2i} = r_i * b_i, where r_i = √[(1 - S_{i-1}/S_i) / S_{n/2}].
  • For odd n, extend the method to n+1 dimensions and normalize the first n components to ensure uniformity on the n-sphere.
  • Use a modified scaling factor r_i = √(1 - S_{i-1}/S_i) to generate points uniformly distributed within the n-ball instead of on its surface.
  • Optimize performance using bucket sorting by grouping points by their S_i values and sorting within buckets to reduce comparison cost in large samples.

Experimental results

Research questions

  • RQ1Can a uniform sampling method on the hypersphere be designed that avoids expensive trigonometric or transcendental functions?
  • RQ2How can Marsaglia’s efficient 3D and 4D sampling techniques be generalized to arbitrary even dimensions?
  • RQ3What is the computational performance gain of using rejection sampling on unit disks and sorting by squared radius compared to standard normal-based methods?
  • RQ4Can the same framework be adapted to sample uniformly within the n-dimensional ball, especially for odd n?
  • RQ5How does the use of bucket sorting improve the efficiency of the algorithm in practice for large-scale sampling tasks?

Key findings

  • The proposed algorithm achieves uniform sampling on the n-sphere without evaluating logarithms, sines, cosines, or higher-order roots, significantly reducing computational cost.
  • For even n, the method uses rejection sampling on unit disks and sorting of squared radii to enable fast, numerically stable coordinate assignment.
  • The algorithm is faster than the standard normal-based method in many practical settings, particularly when trigonometric functions are expensive to compute.
  • The method generalizes Marsaglia’s 3D and 4D techniques by using multiple 2D rejection samples and ordering them by radius to construct higher-dimensional points.
  • A variant of the algorithm generates points uniformly within the n-ball by modifying the scaling factor to r_i = √(1 - S_{i-1}/S_i), though this does not extend cleanly to odd n.
  • The use of bucket sorting reduces the number of comparisons in sorting, improving performance for large-scale sampling, especially when n is large or many samples are needed.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.