Purpose: The purpose of this program is to simulate the tossing of a coin. The proportion of heads is graphed against the number of trials, the number of which is determined by the user. This program is useful for demonstrating the law of large numbers, in that as the number of trials is increased, the observed mean number of heads approaches the expected mean.
Download: You can download this program from within Stata by typing
net from https://stats.idre.ucla.edu/stat/stata/ado/teach net install heads
Use of program: To use this program, in the Stata command window type heads # in the Stata command window, where the number indicates the number of times the coin is to be tossed. There are no options associated with this program.Examples: The following example shows the output of the heads command using one hundred tosses of the coin. Notice that as the number of trials increases, the proportion of heads approaches the expected mean of .5.
The following example shows the output of the heads command using one thousand tosses of the coin.