/* RandomSamp is an applet that Draws graphics Step by step to help students understand the normal distribution of a simple random Sample, despite a distribution which is not itself Normally distributed . - 29 Sept 99 Fr. Chris Thiel, OFMCap */ import java.awt.*; import java.applet.Applet; import java.awt.Graphics; import java.awt.event.*; import java.lang.Math; public class RandomSamp extends Applet { //Global Variables Choice daMenu = new Choice(); int currentStep=0; int lastStep=5; Color buttonColor; int buttonWidth=35; int buttonHeight=20; Rectangle go,back; Point A,B,M,C; int last, samp; int p []; float sampleSum, ss; float sm []; float sd []; private void circumscribe (Graphics g, int centerX, int centerY, int radius, int startArc, int endArc) { double theta []; theta = new double [21]; g.setColor(Color.green); for (int j=0; j <= 20; j++ ) theta[j] = Math.PI*startArc/180 + j*((Math.PI*endArc/180)/20); for (int j=0; j < 20 ; j++) { g.drawLine(centerX +(int)(radius*Math.cos(theta[j])),(int)(centerY-(radius*Math.sin(theta[j]))), centerX +(int)(radius*Math.cos(theta[j+1])), (int)(centerY-(radius*Math.sin(theta[j+1])))); } g.setColor(Color.black); } private void dot (Graphics g, int x, int y, String label) { g.setColor(Color.red); g.fillOval(x-2,y-2,5,5); g.setColor(Color.black); g.drawString(label, x-4 , y-4); } private void fill_p(int n, int y){ for (int i=0;i