fork download
  1. import java.util.Random;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Random rand = new Random();
  5. int N = 10;
  6. for(int i=0; i<N/2; i++){
  7. double u1 = rand.nextDouble();
  8. double u2 = rand.nextDouble();
  9. double r = Math.sqrt(-2 * Math.log(u1));
  10. double theta = 2 * Math.PI * u2;
  11. double z1 = r * Math.cos(theta);
  12. double z2 = r * Math.sin(theta);
  13. System.out.println(z1 + " " + z2);
  14. }
  15. }
  16. }
  17.  
Success #stdin #stdout 0.12s 55932KB
stdin
Standard input is empty
stdout
0.8290246444993473 1.185340286152789
-0.13829308874434484 -0.1973048526607945
-0.23621563885680094 0.4281321396217422
1.2127967547207974 1.334268664247367
0.4963573748487336 0.6422353672294349