public PercolationStats(int N, int T) {
		if (N <= 0 || T <= 0)
			throw new java.lang.IllegalArgumentException("N<=0 or T<=0");
		this.T = T;
		counT = new double[T];
		Percolation percolation;
		for (int i = 0; i < T; i++) { // run open() T times with two random
			int randI = 0, randJ = 0;
			int count = 0;
			percolation = new Percolation(N);
			while (!percolation.percolates()) { // positions
				randI = StdRandom.uniform(N) + 1;
				randJ = StdRandom.uniform(N) + 1;
				if (!percolation.isOpen(randI, randJ)) {
					percolation.open(randI, randJ);
					count++;
				}
				this.counT[i] = count;
			}
		}
		double t1;
		double sum = 0.0, sum2 = 0.0;
		this.confidenceLo = counT[0];
		for (int j = 0; j < T; j++) { // mean
			t1 = counT[j] / ((double) (N * N));
			if (t1 > confidenceHi)
				this.confidenceHi = t1;
			if (t1 < confidenceLo)
				this.confidenceLo = t1;
			sum = sum + t1;
			// System.out.println(counT[i]+" t1= "+t1);
		}
		this.mean = sum / T;
		for (int j = 0; j < T; j++) { // stdev
			t1 = counT[j] / ((double) (N * N));
			sum2 = sum2 + (t1 * t1 - 2 * mean * t1 + mean * mean);
		}
		this.stdev = Math.sqrt((sum2 / (T - 1)));
	} // perform T independent computational experiments on an N-by-N grid