-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPercolationStats.java
59 lines (43 loc) · 1.62 KB
/
PercolationStats.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.ArrayList;
public class PercolationStats {
double mean;
double stddev;
double confidenceLo;
double confidenceHi;
ArrayList<Integer> percolates = new ArrayList<Integer>();
ArrayList<Integer> doesnt_percolate = new ArrayList<Integer>();
public PercolationStats(int N, int T) {
// perform T independent experiments on an N-by-N grid
for( int i = 0; i < T; i++ ) {
Percolation perc = new Percolation(N, 0.5); // p value is chance that any square will be blocked XXX dynamically come up with this value
// System.out.println( "debug: percolates? " + ( perc.percolates() ? "yes" : "no" ) );
// PercolationVisualizer.draw(perc, N);
if( perc.percolates() ) {
} else {
}
}
}
public double mean() {
// sample mean of percolation threshold
return this.mean;
}
public double stddev() {
// sample standard deviation of percolation threshold
return this.stddev;
}
public double confidenceLo() {
// low endpoint of 95% confidence interval
return this.confidenceLo;
}
public double confidenceHi() {
// high endpoint of 95% confidence interval
return this.confidenceHi;
}
public static void main(String[] args) {
// test client
Stopwatch stopwatch = new Stopwatch();
PercolationStats ps = new PercolationStats( Integer.parseInt(args[0]), Integer.parseInt(args[1]) );
double time = stopwatch.elapsedTime();
System.out.println( "runtime: " + time );
}
}