Counting Event Occurrences in a List



It is common in Monte Carlo statistical simulations to have the need to count the frequency of the occurrence of a particular event in a list of outcomes. Here is a really nice way to accomplish that on the TI-83, that as far as I can tell, is NOT shown in the manual. It seems not to work on the -82.

As an example I have placed a short list of values in L1 (figure 1)


Figure 1 ************************** Figure 2

The short line in figure 2 is all that is necessary to count the frequency with which one appears in the list. Here is the sequence of commands to write it:

[2nd], [Stat/List], [LEFT-ARROW], [5], [2nd], [1/L1], [2nd], [Math/Test], , [1],

This method works directly with a list on the home screen using [2nd], [ans].

Here is a quick illustration that shows the method applied to a simulation for a common problem in probability and statistics:

Suppose we wanted to find the probability that a family with four children has no male children. If we assume that the birth of each child is an independent event and the probability of a male is 1/2, we can simulate this as a binomial event. We will use the "randBin(" selection under the Math/Prb sub-menu to simulate the number of males in ten random families with four children. The following commands will produce the desired list on the home screen: [MATH], [LEFT ARROW], [7], will produce "randBin(" on the screen. Now enter four, for the number of children, a comma and then .5 as the independent probability of a male child, and then another comma and 10 to produce ten trials. Finally close the parenthesis and press . Something similar to the following should appear.

Figure 3 ******************** Figure 4

Now we want to know how many of these ten families have NO male children, so we use the method from above to count the incidence of the event "0" in the list. The command should read "Sum(ans=0)" and then press enter. My results appear as in the figure above. With a probability of approximately .06, it is not unusual that I had no families in such a small sample with zero male children. By changing the "10" to "50" students can sample a larger population. A classroom can pool their resources and sample a small city of families in a matter of a few minutes.

Pat Ballew,

Misawa, Jp