Uniform Distribution on a Sphere: Part 1 (First Attempt)

(Despite the title, this is the second post in the series. Part 0 covered the definition of uniform distributions in discrete and continuous space. If this last sentence makes no sense, go back and read Part 0.)

Instead of tackling the problem of picking a point on a sphere right away, let’s consider the easier problem of picking a point on a circle. We will then extend this method to the harder problem. (Mathematicians like to do this.)

Consider the usual two-dimensional coordinate space with x and y axes. We set a point called the origin and then any other point can be described by the distance we travel from the origin in the x-direction (east/west) and the y-direction (north/south). When we put these two distances together they are called coordinates and we write them as (x,y) where x and y are the distances traveled in each direction. (Note that positive distances represent movement east and north and negative numbers represent movement west and south.) In this notation the origin becomes (0,0).

Unit circle
Figure 1: The unit circle in Cartesian coordinates

Now we will place a circle centered on the origin with radius 1; this is called the unit circle. Using the Pythagorean Theorem (Figure 1), we can see that all points on this circle must satisfy the equation x^2+y^2=1. This equation is a concise way of describing the unit circle in this coordinate system. Our problem will be to pick coordinates (x,y) uniformly at random that are on this circle—i.e., that satisfy x^2+y^2=1.

From our discussion of uniform distributions in the last post, we know that we could pick numbers x and y each uniformly at random from an interval. However this does not help us satisfy the equation x^2+y^2=1. In fact, if we just picked random coordinates this way there is zero probability they would fall on the circle. (Think back to the previous post where we said that mass=density\cdot volume. In this two-dimensional setting, “volume” is area. The circle—remember we are just thinking of the points that make up the circle, not its interior—has no area and therefore no mass.)

Polar coordinates
Figure 2: The unit circle in polar coordinates

So let’s try something else instead. We will change coordinate systems. Instead of representing points (x,y) with distances in two directions from the origin, we will use (r,\theta) where r is a distance (radius) from the origin and \theta is an angle. The former are called Cartesian coordinates while the latter are called polar coordinates. Figure 2 shows how we define the angle \theta. (Note that we are measuring angles in radians. Imagine a (big) pie with a 1-foot radius. A slice covering an angle of 1 radian is a slice that has a 1 foot circumference. Angles in radians relate directly to the size of the arc they cut out from the pie. See Figure 3 for an illustration of this principle. This will be useful in a second!)

Figure 3: The relationship between radians and arc length

Now we know that since our circle has radius one, all the points on the circle in polar coordinates have r=1. This means that to get a point on the circle, we only have to choose an angle \theta. Instead of the two-dimensional choice before that required us to satisfy an algebraic equation, we have a one-dimensional choice that will automatically satisfy our requirements. So we now pick an angle uniformly at random from the interval [0,2\pi] (remember: we are using radians). Will choosing an angle actually give us a uniformly random point on the circle?

Yes. You may think this is an obvious answer, but it will be important for us later to realize why this is true. Recall the equivalent definition of a continuous uniform distribution from the previous post:

Given a uniform probability distribution, subintervals of equal “volume” have equal mass.

In this case subintervals of our circle correspond to arcs and “volume” corresponds to arc length. Remember the discussion above about radians (refer back to Figure 3). Well that gives us a direct relationship between angles and arc length. Equal angles mean equal arc lengths. And so if our subintervals of angles have equal mass, then our subintervals of arcs have equal mass as well! Thus we are indeed choosing points uniformly at random on the circle.

Spherical coordinates
Figure 4: The spherical coordinate system

Let’s extend this method to work on the sphere. We add another angle to our coordinate system to describe the inclination out of the plane. Our new coordinates are given by (r,\theta,\phi), and we call them spherical coordinates (think latitude and longitude). See Figure 4 for to see our naming convention for these angles (note that physicists swap \theta and \phi, but that doesn’t matter to us). As before, all points on the surface of the sphere have radius 1. So now we will just choose each angle uniformly at random. Simple, right? Figure 5 shows two views of 2,500 random points chosen this way. (We're only choosing points on the upper hemisphere to make the picture easier to see.)

Non-uniform points on a sphere
Figure 5: Top view (left) and front view (right) of points on a sphere with \theta and \phi chosen uniformly at random

Uh-oh. Those points do not look very uniform, do they? They seem bunched together in the center of the left image. This violates our equal volume/equal mass rule. While this could just be dumb luck, if we repeat this experiment and pick another 2,500 points “uniformly” at random we will see the same thing (trust me). Clearly something went wrong.

Continue on to Part 2 for the explanation.