To estimate the percolation threshold, perform the following computational experiment on a percolation object:
To obtain an accurate estimate of the percolation threshold, repeat the experiment T times and average the results. Let xt be the fraction of open sites in experiment t. The sample mean, μ, provides an estimate of the percolation threshold. The sample standard deviation, σ, measures the sharpness of the threshold. You can calculate these values as follows (notice the right formula is for σ2):
Assuming T is sufficiently large (say, at least 30), the following provides a 95% confidence interval for the percolation threshold:
You will write a client program, PercolationStats, that prompts the user for N and T, performs T independent experiments on an N-by-N grid, and prints out the 95% confidence interval for the percolation threshold. Use java.util.Random to generate random numbers and follow steps above to compute the sample mean and standard deviation. Below is an example run with N=200 and T=100.
mean percolation threshold = 0.5921
stddev = 0.0098
95% confidence interval = [0.5902, 0.5940]
total time = 2.074s
mean time per experiment = 0.02074
stddev = 0.00376