Re:My Most Interesting Interview Problem
by gibybo on Wednesday September 11, 2013 @11:36AM
(#6367828)
For a ball, can't I just randomly generate two angles (0-2pi)?
[ Parent
| on HN ]
Re:My Most Interesting Interview Problem
by mturmon on Wednesday September 11, 2013 @11:45AM
(#6367875)
No, because the two angles can't easily be combined to make the resulting point uniform on the sphere.
For instance, if you call one of the angles "latitude", and one "longitude", then you will get too many samples near the poles -- think about how the lines of constant longitude start out widely spaced on the equator, but then converge at the poles. This would cause points to pile up at the poles.
Your proposal hits on the nub of why this problem is hard. It is, in general, hard to generate a bunch of non-independent random variables with a prescribed distribution. In this case, it's the angles that are not independent.
Re:My Most Interesting Interview Problem
by gibybo on Wednesday September 11, 2013 @12:01PM
(#6367985)
Ah, of course, thanks.
Re:My Most Interesting Interview Problem
by andrewcooke on Wednesday September 11, 2013 @12:42PM
(#6368236)
you can use longitude and z (height "up the axis") (it's uniform because a ring of thickness dz at height z is of area 2pi * z * cos(lat) * dz/cos(lat) (so the latitude cancels nicely - it's a trick used for equal area map projections).
Re:My Most Interesting Interview Problem
by ColinWright on Wednesday September 11, 2013 @11:41AM
(#6367859)
> For a ball, can't I just randomly generate
> two angles (0-2pi)?
Why would that be uniformly distributed?