TITLE: How to find a random axis or unit vector in 3D?
QUESTION [47 upvotes]: I would like to generate a random axis or unit vector in 3D. In 2D it would be easy, I could just pick an angle between 0 and 2*Pi and use the unit vector pointing in that direction. 
But in 3D I don't know how can I pick a random point on a surface of a sphere.
If I pick two angles the distribution won't be uniform on the surface of the sphere. There would be more points at the poles and less points at the equator.
If I pick a random point in the (-1,-1,-1):(1,1,1) cube and normalise it, then there would be more chance that a point gets choosen along the diagonals than from the center of the sides. So thats not good either.
But then what's the good solution?

REPLY [5 votes]: George Marsaglia, in this paper, gives the following proposal:

Keep generating independent random values $v_1$ and $v_2$ in $(-1,1)$ until $s=v_1^2+v_2^2 < 1$, then the random point on the sphere is formed as $(2v_1\sqrt{1-s},2v_2\sqrt{1-s},1-2s)$

See the paper for details on how it works.