Domanda di colloquio di Google

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

Risposte di colloquio

Anonimo

5 dic 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)

Anonimo

4 mar 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.