public PercolationStats(int N, int T) {
        if (N <= 0 || T <= 0)
            throw new IllegalArgumentException("T or N is not larger than 0!");
        this.T = T;
        noOfOpenSites = new double [T];
        for (int k = 0; k < T; k++) {
            Percolation perc = new Percolation(N);
            while (!perc.percolates()) {
                int i = StdRandom.uniform(1, N+1); // row index
                int j = StdRandom.uniform(1, N+1); // column index
                if (!perc.isOpen(i, j)) {
                    noOfOpenSites[k] += 1.0 / (N * N);
                    perc.open(i, j);
                }
            }
        }
    }