The heads program can be used to
produce results simulating those shown in Figure 5.1. In the example in the book,
the number of bad switches are examined, so whenever you think of getting a
"head" with the heads program, it is like getting a bad switch. The
example draws 10 switches (coins) at a time and does this for 1000 trials. The data
for this can be generated with the heads command below.

heads , save

Then click on quit and the graph in Figure 5.1 can be produced with the graph command below.

histogram heads, discrete xlabel(0(1)6)

The graph we got is shown below, and looks much like
(but not exactly like) Figure 5.1. You can vary the number of trials, and you will
find that as you increase the number of trials (from 1000) the graph will look more and
more exactly like figure 5.1.

The heads program can be used to
produce results like that in figure 5.4. The only difference from figure 5.1 above
is that there are 100 switches drawn at a time (or the equivalent of tossing 100 coins at
a time. This is illustrated below.

Figure 5.5 illustrates the area under the curve using the normal approximation to the binomial.
There is an excellent demonstration of this at the
Rice Virtual Lab in Statistics at
http://www.ruf.rice.edu/~lane/stat_sim/normal_approx/index.html If you choose an N of 100, P of .1,
and to show the probability from 0 to 9, you see that you get the results shown at the bottom of page 386
corresponding to figure 5.10. You can see that the exact probability is .45 vs. the
normal approximation of .43. You can vary the N and see that as the N decreases, the
discrepancy between these two results increases, and as the N increases, the discrepancy
decreases. In other words, the accuracy of the "normal approximation"
improves with as the N gets greater and greater.

Figure 5.5 illustrates how the distribution of sample
means becomes more and more normal as the sample size increases. The first figure
(5.5a) appears like an exponential distribution with sample size of 1, and the following
figures have a sample size of 2, 10 and 25. We can use the clt
program (central limit theorem) to illustrate this. The examples below draw 1000
sample means from an exponential distribution with sample sizes of 1, 2, 10 and 25.

clt

Sample size of 1

Sample size of 2

Sample size of 10

Sample size of 25

In addition to the examples above, you can try any
sample size you like by the N per sample pulldown.Likewise, you can try other distributions including a
log distribution, or a normal bimodal distribution, or a uniform distribution.

Below we show one more example where we used a log
normal distribution with a sample size of 100 and drawing 5000 sample means, and showing a normal
overlay so we can compare the results to a normal distribution.

Below we started with a parent population that was
skewed, and chose to see the distribution of the mean with N=10 and N=20, and a normal
overlay. You can see that as the N went from 10 to 20, the distribution became more
normal in shape. This demonstration allows you to choose other parent populations,
and even allows you to make a custom population by clicking the mouse on the parent
distribution to alter the shape of the distribution.