public static void main(String[] args) {
		Random gen = new Random();
		  int n;
		  if (args.length == 1) {
		    n = Integer.valueOf(args[0]);
		  } else {
		    n = gen.nextInt(50) + 1;
		  }
		  List<Double> T = new ArrayList<Double>(n);
		  iota(T, n, 0);
		  List<Double> P = new ArrayList<Double>();
		  double full_prob = 1.0;
		  for (int i = 0; i < n - 1; ++i) {
		    double pi = gen.nextDouble() * full_prob;
		    P.add(pi);
		    full_prob -= pi;
		  }
		  P.add(full_prob);
		  
		  simplePrint(T);
		  System.out.println();
		  
		  simplePrint(P);
		  System.out.println();
		  
		  System.out.println(nonuniform_random_number_generation(T, P));
		  // Test. Perform the nonuniform random number generation for n * kTimes times
		  // and calculate the distrbution of each bucket.
		  int kTimes = 100000;
		  int[] counts = new int[n];
		  for (int i = 0; i < n * kTimes; ++i) {
		    double t = nonuniform_random_number_generation(T, P);
		    ++counts[(int) t];
		  }
		  for (int i = 0; i < n; ++i) {
		    System.out.println((double) (counts[i]) / (n * kTimes) + " " + P.get(i));
		    assert Math.abs(((double) counts[i]) / (n * kTimes) - P.get(i)) < 0.01;
		  }
	}