Below are two simple calculator programs, FAIR and BIASED. FAIR simulates flipping an unbiased coin (the probability of heads is 50% and the probability of tails is 50%), and BIASED simulates flipping a coin that is biased in favor of 60% heads and 40% tails. The programs are very similar, differing in just two places: FAIR uses randInt, and BIASED uses rand.

Enter both programs into your calculator, and run them for, say, 50 trials. Record the outcomes. Can you tell from the outcomes which program was run? Repeat runs of fifty (or more) trials several times.

Here are eight trials that I got from my calculator.

FAIR

First trial: after fifty tosses: Heads, 29; Tails, 21

Second trial: after fifty tosses: Heads, 22; Tails, 28

Third trial: after fifty tosses: Heads, 27; Tails, 23

Fourth trial: after fifty tosses: Heads, 24; Tails, 26

Total after 200 tosses: Heads, 102; Tails, 98 (102/200=51% heads)

BIASED

First trial: after fifty tosses: Heads, 28; Tails, 22

Second trial: after fifty tosses: Heads, 26; Tails, 24

Third trial: after fifty tosses: Heads, 24; Tails, 26

Fourth trial: after fifty tosses: Heads, 31; Tails, 19

Total after 200 tosses: Heads, 109; Tails, 91 (109/299=54.5% heads)

PROGRAM:FAIR

:0→H

:0→T

:While 1

:randInt(0,1)→A

:If A=0

:Then

:Disp “HEADS”

:H+1→H

:End

:If A=1

:Then

:Disp “TAILS”

:T+1→T

:End

:{H,T}→L1

:Disp L1

:Pause

:End

To stop the program, press ON 1 or ON 0.

PROGRAM:BIASED

:0→H

:0→T

:While 1

:rand→A

:If A≤.6

:Then

:Disp “HEADS”

:H+1→H

:End

:If A>.6

:Then

:Disp “TAILS”

:T+1→T

:End

:{H,T}→L1

:Disp L1

:Pause

:End

To stop the program, press ON 1 or ON 0.

Do you see the differences in the programming code in the two programs?

Lesson Index