This macro simulates the tossing of a coin a specified number of times, and calculates the total number of tosses, the total number of heads, the proportion of heads, and the difference between the total number of heads and the total number of tails.

## Download the Macro

Be sure that Minitab knows where to find your downloaded macro. Choose . Under Macro location browse to the location where you save macro files.

###### Important

If you use an older web browser, when you click the Download button, the file may open in Quicktime, which shares the .mac file extension with Minitab macros. To save the macro, right-click the Download button and choose Save target as.

## Running the Macro

To run the macro, click anywhere in the Session window and choose . At the command prompt (MTB>), type the following:

%COUNTHEM

Press Enter.

When you are prompted, enter the number of times to toss the coin, and the number of sets to toss the coin that many times. For example, if you wish to toss the coin 50 times and repeat that 5 times for a total of 250 tosses, enter 50, 5 and press Enter.

## More Information

Results of 100 tosses performed one time.

ROW NUMTOSS NUMHEADS PROPORTN DIFF
1 100 52 0.52 4

You can see that 100 tosses yielded 52 heads.

Results of 100 tosses performed 10 times

ROW NUMTOSS NUMHEADS PROPORTN DIFF
1 100 52 0.520000 4
2 200 101 0.505000 2
3 300 147 0.490000 -6
4 400 198 0.495000 -4
5 500 252 0.504000 4
6 600 294 0.490000 -12
7 700 347 0.495714 -6
8 800 396 0.495000 -8
9 900 454 0.504444 8
10 1000 509 0.509000 18

The proportion of heads appears to be approaching 0.5. The differences between the number of heads and the number of tails have varied widely.

**Investigate with graphs**

If you create a scatterplot of the proportion of heads (PROPORTN) against the number of tosses (NUMTOSS) you will notice that it is approaching 0.5.

If you create a scatterplot of the differences between the number of heads and the number of tails (DIFF)versus the number of tosses (NUMTOSS) you will notice something completely different.