//ArrayGauss.java import javax.swing.*; import java.awt.*; import java.util.*; //Arrays utility class public class ArrayGauss extends JApplet { public void init () { String input; input = JOptionPane.showInputDialog(null,"Population Mean?", "Enter an integer", JOptionPane.QUESTION_MESSAGE); int mean = Integer.parseInt(input); input = JOptionPane.showInputDialog(null,"Population Standard deviation?", "Enter an integer", JOptionPane.QUESTION_MESSAGE); int sd = Integer.parseInt(input); input = JOptionPane.showInputDialog(null,"Sample size?", "Enter an integer", JOptionPane.QUESTION_MESSAGE); int size = Integer.parseInt(input); int[] A = new int[size]; input = JOptionPane.showInputDialog(null,"Number of samples?", "Enter an integer", JOptionPane.QUESTION_MESSAGE); int samples = Integer.parseInt(input); //a JTextArea to display stuff JTextArea textarea = new JTextArea(20,80); textarea.setLineWrap( true ); textarea.setFont( new Font("Courier",Font.BOLD,18) ); //a JScrollPane to attach to the textarea JScrollPane scrollpane = new JScrollPane(textarea); int showDataUnsorted, showDataSorted; showDataUnsorted = JOptionPane.showConfirmDialog(null,"Show the (unsorted) sample data?", "show the data?", JOptionPane.YES_NO_OPTION); showDataSorted = JOptionPane.showConfirmDialog(null,"Show the sorted data?", "show the data?", JOptionPane.YES_NO_OPTION); Random gen = new Random(); for (int sample=1; sample<=samples; sample++) { long sum=0; //generate normally distributed random ints with mean and variance for (int i=0; i=sampleMean-sampleSD && A[i]<=sampleMean+sampleSD) sd1++; if (A[i]>=sampleMean-2*sampleSD && A[i]<=sampleMean+2*sampleSD) sd2++; if (A[i]>=sampleMean-3*sampleSD && A[i]<=sampleMean+3*sampleSD) sd3++; } textarea.append("\n\nN="+size+ " Sample Mean: "+sampleMean+ " Sample standard deviation: "+sampleSD); textarea.append("\n%data +/- 1 s.d. from mean: "+((double)sd1/size)); textarea.append("\n%data +/- 2 s.d. from mean: "+((double)sd2/size)); textarea.append("\n%data +/- 3 s.d. from mean: "+((double)sd3/size)); textarea.append("\nMin: "+A[0]+ " 1Q: "+A[A.length/4]+ " Median: "+A[A.length/2]+ " 3Q: "+A[3*A.length/4]+ " Max: "+A[A.length-1]+ " IQR: "+(A[3*A.length/4]-A[A.length/4])); int maxRun=1, maxRunNum=A[0], currentRun=1; for (int i=1; i maxRun) { maxRun = currentRun; maxRunNum = A[i]; } } else currentRun = 1; textarea.append("\nMode: "+maxRunNum+ " #times: "+maxRun); int anotherNumber=1; for (int i=1; i