-
Method 1: rejection sampling: sample uniformly in a cube, then reject points outside the unit sphere.
-
Method 2: polar sampling: use polar coordinates to directly generate points uniformly in the sphere
There are two implementations here. One in JavaScript, one in C. Which method is faster is different depending on the language!