* CLTdemo.sas; * This program generates variables which are means of random variables and then plots the means. The size of the sample on which the means are based varies by sample size. The Binomial distribution is used to generate the first example because of it's marked difference from the normal when n is small. The Uniform distribution is used to generate the second example. That generator produces data between 0 and 1, with a standard deviation = 1/sqrt(12) = 0.2887; * The program is deliberately simple so that others can adapt it to different statistical packages without much effort. My apologies to those who like elegant code; * Last revised 3/21/96 -- David C. Howell; Options ls = 78; Options FormDlim = '-'; * The following data step draws random numbers from a Bernoulli population. This just means that we draw a bunch of 0's and 1's and take their mean. For example, when n = 5, the mean is the mean of 5 numbers.; Data Binomial; seed = -1; * Using a seed with a negative value gives different data each time the program is run. The seed is for the random number generator; Do Observ = 1 to 1000; Mean1 = ranbin(seed, 1, .25); Mean5 = ranbin(seed, 5, .25); Mean10 = ranbin(seed, 10, .25); Mean30 = ranbin(seed, 30, .25); Output; end; Run; Proc Chart Data = Binomial; vbar Mean1 Mean5 Mean10 Mean30; Run; Data Uniform; Seed = -1; Do Observ = 1 to 1000; Mean1 = ranuni(seed); Mean5 = 0; Mean10 = 0; Mean30 = 0; Do N5 = 1 to 5; Mean5 = Mean5 + ranuni(seed); end; Mean5 = Mean5/5; Do N10 = 1 to 10; Mean10 = Mean10 + ranuni(seed); end; Mean10 = Mean10/10; Do N30 = 1 to 30; Mean30 = Mean30 + ranuni(seed); end; Mean30 = Mean30/30; Output; end; run; Proc Chart Data = Uniform; vbar mean1 Mean5 Mean10 Mean30; run;