How can I generate points randomly distributed on a sphere?

That is, how can I generate points that are equally distributed over the
area of the sphere? It won't work, for example, to generate (uniformly
distributed) random latitudes and (uniformly distributed) random longitudes,
because any specified interval of latitude includes a much larger area
when it is near the equator than when it is near a pole, so this "method"
will generate a much larger areadensity of points near the poles than
near the equator.

The trick is to know that the area of a sphere's surface contained between
two parallel planes that both cut the sphere depends only on the distance
between the planes, not on where they cut it.

Set up a coordinate system (z,phi) where z is an axis that runs from south
pole to north pole (z = R to +R, where R is the sphere's radius), and
where phi is the longitude, which runs (say) between 0 and 2 pi (radians).
The area of a surface patch between z and z+dz, phi and phi+dphi then depends
only on dz and dphi, not at all on z or phi.

To generate a random point on the sphere, it is necessary
only to generate two random numbers, z between R and R, phi between 0
and 2 pi, each with a uniform distribution

To find the latitude (theta) of this point, note that z=Rsin(theta), so
theta=sin^{1}(z/R); its longitude is (surprise!) phi.

In rectilinear coordinates, x=Rcos(theta)cos(phi), y=Rcos(theta)sin(phi),
z=Rsin(theta)= (surprise!) z.

Needless to say, (x,y,z) are not independent, but are rather constrained
by x^{2}+y^{2}+z^{2}=R^{2}.