Google Interview Question

Sample uniformly on a circle centered at zero with radius 1.

Interview Answers

Anonymous

Mar 4, 2011

randomly choose points in the rectangular from (-1,-1) to (1,1) and delete those points that fall out of the circle by checking x^2 + y^2 <=1.

Anonymous

Dec 5, 2011

randomly generate an integer X. we know that cos(X)^2 + sin(X)^2 = 1, so just use xx = cos(X) and yy = sin(X) I think that was the whole point of the question (and I don't like it very much)