static int simulate_biased_coin(int n, int trails) {
		// random num generator 
		// we use it to generate random double in [0.0, 1.0]
		Random gen = new Random(); 
		double kBias = 0.4;
		int fails = 0;
		for (int i = 0; i < trails; ++i) {
			int biased_num = 0;
			for (int j = 0; j < n; ++j) {
				biased_num += (gen.nextDouble() >= kBias ? 1 : 0);
			}

			if (biased_num < (n >> 1)) {
				++fails;
			}
		}
		return fails;
	}