Suppose a coin is biased to show heads 10% more than it shows tails. Would you notice it? What kind of analysis would you make to try to detect it? (There have been cases in court about similar questions!)
Let's simulate tossing a coin when the coin is biased 10%.
Let's let 1 stand for heads and 0 stand for tails.
We will use rand, which gives a random number between 0 and 1.
rand < .55
will yield 1 if rand is less than .55, and 0 if rand is greater than or equal to .55 (so there is a bias of 10% for a 1, namely, heads).
We want to generate a random sequence of 100 ones and zeros with a bias of 10% toward ones, and see how many of each we get.
"rand(100) < .55"→Str1
Str1 stands for string1.
Comment:
Quotes around an expression on TI calculators indicate that what is between
quotes should be stored character-by-character.
r a n d ( 1 0 0 ) < .55
It can be read, "ar a en dee left-paren one zero zero ... five five"
Such a string can be complete nonsense. Try, for example:
"532,ABC*+"→Str3 ENTER
A string of characters can be stored and displayed even when it is meaningless.
But when you want to read this string as a mathematical expression, you use, expr(Str3).
But now if the string is not a correct expression, you'll get an error message.
Try, expr(Str3) ENTER and see what happens. expr is under CATALOG.
Now let’s see what our sequence looks like. We want to get expr(Str1). It is under CATALOG. You can get it faster by pressing CATALOG E, and then pressing the down arrow until you see expr:
expr(Str1)
You will see a list:
{1 0 0 1 1 0 1 ….}
Next, store the list in, say, L6.
Ans→L6
Check that you got 100 entries on your list:
dim(L6)
You should see
100
Now find out how many of those 100 entries are ones (i.e., “heads”):
sum(L6)
What did you get? (I got 61.)
You can repeat this to get more coin flips. Start again with “rand(100) < .55”→Str1
(You can get to it with 2nd ENTRY 2nd ENTRY….)
Would you be suspicious that the coin is biased?
Later in the course, we will learn how to compute the theoretical probability that, if the coin were fair, you would get 61 (or any other number of) heads by chance!