7350 coin flips on a GDC

Monday 18 May 2020

It’s pretty clear after a look around my site that I have a clear preference for the TI-Nspire CX when it comes to choosing a graphic display calculator (GDC). Some day – who knows when – handheld devices will not be the technology tool used on exams. For the time being, a handheld calculator that has no QWERTY keyboard, no stylus and no computer algebra (CAS) is the allowed technology on Paper 2 and Paper 3 (HL) exams. I prefer the TI-Nspire for many reasons. One simple reason is its versatility. The TI-Nspire is not only a very user-friendly and powerful device for doing maths (calculating, graphing, solving, spreadsheet, data analysis, etc), but it is equally useful for investigating maths (and quite good at presenting results too).

Here is an example. I was writing some materials for introducing probability and discussing the difference between theoretical and experimental probabilities. The simplest experiment to illustrate this is to flip a fair coin (heads/tails) a large number of times and observe that as the number of flips (trials) increases the experimental probability of obtaining heads (i.e. the relative frequency of heads) becomes ever closer to the theoretical probability of \(\frac{1}{2}\). A short computer / calculator program can model the flipping of a coin and to have it ‘perform’ a very large number of flips by simply having the program execute some instructions embedded in a loop of some kind. It is not difficult to write such a program on most GDCs. Programming any TI-84 calculator or TI-Nspire in TI Basic can be carried out by just about any secondary school student (and even younger). The chapters on programming in the guidebooks for all TI-84 models and the TI-Nspire are very helpful and include clear examples.

The interesting part is presenting the results of all the coin flips done by the calculator program. It could just display the numerical result for the relative frequency of heads (and/or tails) and maybe include a simple histogram. I thought a more thought-provoking display would be to have a screen pixel turned on or off depending on whether or not a particular flip of the coin (actually a random number generator producing a 0 or 1) is heads (1 = pixel on) or tails (0 = pixel off). There is a specific command on TI-84 calculators that does turn a pixel on or off. There is no such command on the TI-Nspire but there is a work around. You can display a scatter plot in the Graph application and set the ‘attributes’ so that the plotted points are shown as a small square. A small square plotted to represent a data point in a scatter plot consists of nine pixels (3 x 3 square). The TI-Nspire screen is 318 pixels wide and 212 pixels high (much higher screen resolution than a TI-84). I determined that Window Settings of Xmin=0, Xmax=106, Ymin=0, Ymin=71 will work to display a screen that is 105 ‘pixels’ wide (actually scatter plot points) by 70 pixels high.  Since 70 x 105 = 7350 then a TI-Nspire screen can display the results of 7350 coin flips (one example shown here).

Last school year, I discussed this GDC ‘investigation’ with students and given their interest level I actively encouraged them to try and write a program on their TI-Nspire to display 7350 coin flips (optional task). At the bottom of this blog entry are two student-written TI-Nspire programs (with some minor edits from me) – coin_flips_v1 and coin_flips_v2 – that successfully completed the task. coin_flips_v2 has fewer lines of code – so it’s more efficient – but both get the job done. Note: The programs produce two lists (list1 & list2) which need to be graphed in the Graph application set on Scatter Plot mode (x→list1, y→list2) with the Window Settings given above along with all the screen info hidden (labels, text & axes).

The screen display for the results of 7350 coin flips initiated some interesting questions in class (a picture of randomness?). The most interesting question was about strings of consecutive heads or tails that could be seen on the screen. The results of the coin flips are entered as 70 rows so horizontal white spaces are showing consecutive tails and horizontal blue rectangles show consecutive heads. Analyzing the results of 7350 coin flips displayed in the image at left showed that there was one string of 13 consecutive heads (circled in red). Students thought that was very unusual. But is it? There is some very interesting mathematics related to the study of consecutive runs of heads or tails in coin flips; or, more generally put, consecutive outcomes in a sequence of Bernoulli trials. I think this area of probability theory might provide an interesting Exploration topic for a suitably motivated HL student. Here are a couple of interesting articles to get started with.

Long Run Predictions by Mark Schilling (MAA Math Horizons, Spring 1994)

How many flips to get n consecutive heads? (university course notes)

 


 


Addendum:  It's easy to include a few lines of code (as is done in coin_flips_v2 above) to compute the relative frequency (experimental probability) of the # of heads or tails (see below). An enterprising student could also have the program analyze list2 to determine the longest consecutive run of heads or tails in the 7350 coin flips. Interesting ...