Question: Modify PercolationProbability to produce output like that produced by Bernoulli (PROGRAM 2.2.6). Extra credit : Use your program to validate the hypothesis that the data
Modify PercolationProbability to produce output like that produced by Bernoulli (PROGRAM 2.2.6). Extra credit : Use your program to validate the hypothesis that the data obeys a Gaussian distribution.

Program 2.2.6 Bernoulli trials public class Bernoulli { public static int binomial (int n) { // Simulate flipping a coin n times; return # heads. } int heads 0; for (int i = 0; i < n; i++) if (StdRandom.bernoulli (0.5)) heads++; return heads; public static void main(String[] args) { // Perform Bernoulli trials, plot results and model. int n = Integer.parseInt(args[0]); int trials = Integer.parseInt(args[1]); n number of flips per trial int[] freq = new int[n+1]; trials number of trials for (int t = 0; t < trials; t++) freq [binomial (n)]++; freq[] experimental results double[] norm = new double[n+1]; norm[] normalized results. for (int i = 0; i
Step by Step Solution
3.46 Rating (143 Votes )
There are 3 Steps involved in it
Lets break it down into a clean solution with modular parts Analysis Need to change PercolationProbability to fit Bernoulli trials output Add Gaussian distribution validation Focus on visualization of ... View full answer
Get step-by-step solutions from verified subject matter experts
