Three Different Algorithms for Generating Uniformly Distributed Random Points on the N-Sphere Jan Poland Oct 24, 2000 Abstract We present and compare three different approaches to generate random points on the N -sphere: A simple Monte Carlo algorithm, a coordinate-by-coordinate strategy and a method based on the rotation invariance the normal distribution. The latter algorithm is the fastest. 1 Introduction Computer scientists sometimes encounter the problem of generating random points on the N -dimensional unit sphere SN = {x ∈ RN +1 : ‖x‖2 = 1}. In most cases, the random points should be distributed uniformly. For this task, there exists a nice little algorithm already mentioned in Knuth ([3]), that is based on the fact that the N -dimensional normal distribution is in- variant under rotation. This algorithm is indubitably the most efficient, in particular in high dimensions. But if a special non-uniform distribution is re- quested, it may be profitable to know other approaches such as a coordinate- by-coordinate strategy or a simple rejection method. When N is small, each algorithm is sufficiently fast, and the problem is not very interesting. For the 1-sphere, i.e. the unit circle in R2, U = (cos(α), sin(α)) with α uniformly distributed in [0, 2π] does the job. Here, we will concentrate on the high dimensional case. Applications are for example in the initialization of a counterpropagation neural network (see [7]) or a variant of generalized continuous recombination in an evolution strategy (cf. [4]). Other discussions of our problem can be found in [6] or [5]. 2 A Monte-Carlo algorithm An immediate algorithm is the following. Take a random point in [−1, 1]N +1 and project it onto the unit sphere . This results in a non-uniform distri- bution, therefore one extra step is necessary. Generate a random point in X ∈ [−1, 1]N +1 and reject it if it is outside the unit ball, i.e. ‖X‖ > 1. If not, U = ‖X‖−1 ·X gives a random point on SN (neglecting the unlikely case that X = 0), and produces a uniform distribution on the sphere. This algorithm is often referred to as the rejection method (see [6]). The major drawback of the algorithm is it’s expected running time: It grows worse than exponentially in N . This is due to the fact that the volume of the N -dimesional unit ball V (N ) = π N 2 Γ(1 + N 2 ) more than exponentially decreases as N → ∞, where Γ(·) is the gamma function Γ(x) = ∫ ∞ 0 e−t · tx−1 dt. 3 The coordinate approach In high dimensions, the distribution of each single coordinate of a uniformly distributed random point U on the N -sphere becomes quite complicated. Suppose we are given a random vector U uniformly distributed on SN . Consider the projection U1 of U to its first coordinate, lets say the x-coordinate. Then the density function f1(x) of U1 is a bounded function from [−1, 1] into R+. We now want to state the f1 explicitely. The following computations will need the incomplete beta function Bx(a, b) ...