Suppose you repeatedly draw three tokens out of six from a bag. The colors of the six tokens are as follows: three are red, two are yellow, and 1 is green.
There is one way to draw 3 reds, there are 6 ways to draw 2 reds and 1 yellow, 3 ways to draw 2 reds and a green, 3 to draw 1 red and 2 yellows, 3 to draw a red, yellow, and green, and 1 to draw 2 yellows and a green.
So there are 20 possible ways (1 + 6 + 3 + 3 + 6 + 1) that 3 tokens can be drawn from 6, and they result in 6 different combinations of colors. The combinations of colors and their probabilities are given in the table below the program.
(See https://www.math.nmsu.edu/%7Ebreakingaway/Statistics/Marbles/Activity1.html for this derivation.)
The program STAT below simulates this task.
The statements to the right of the program explain what happens in each line of code.
Set WINDOW as follows:
Xmin=.5
Xmax=6.5
Xscl=1
Ymin=0
Ymax= .6
Yscl=.2
Set STAT PLOT
Plot1 On
Choose the third type, histogram.
Xlist: L1
Freq:L2
Before you run the program, set values for A, B, and C.
A determines how often you see the current frequencies of the six different outcomes.
B determines how often you see the histogram of those frequencies.
C determines when you are asked if you want to quit the program.
Experiment with different values. We found these to be reasonable:
20→A
60→B
120→C
PROGRAM:STAT
:6→dim(LR) | There are 6 different possible outcomes one can draw. The number of times each one is drawn is kept in list R. |
:Fill(0,LR) | List R starts with six zeroes. |
:{0,.05,.20,.50,.80,.95}→LP
|
List LP holds cumulative probabilities for the 6 outcomes shifted by one position (see table below) |
:0→T | In T, the value 0 means “no”, and the value 1 means “yes”. |
:0→N | Variable N holds the current number of draws. |
:While not(T) |
The program runs as long as T=0. (“not(T)” means “yes”) |
:N+1→N | The count of the number of draws is upped by 1. |
:rand→Q | A random number between 0 and 1 is stored in Q. It determines which of the six possible outcomes happens. |
:sum(Q≥LP)
→I |
I is the location of one out of six outcomes of a draw; see the table below. |
:LR(I)+1→LR(I) | The count of the number of draws in location I is upped by 1. |
:If fPart(N/A)=0 :Then |
When A divides N with no remainder, the list of frequencies is displayed. |
:Disp round(E2LR/N,0),N | You see the list of frequencies rounded to the nearest whole percent, and the number of draws that has been made. |
:Pause |
The program waits. |
:End |
End of “If… Then” |
:If fPart(N/B)=0 :Then |
When N is divisible by B, then the histogram of frequencies is displayed. |
:{1,2,3,4,5,6}→L1 |
The list of outcomes and frequencies are given to STAT PLOT1. |
:LR/N→L2 | How to set the window for STATPLOT is shown above. |
:0→K |
The value of variable K will change to 1 when you press any key. |
:While not(K) | The histogram of frequencies is shown until you press any key. |
:DispGraph |
You may need to hold the key down for as long as one second. |
:getKey→K |
|
:End | End “While not(K)” |
:End |
End “If… Then” |
:If fPart(N/C)=0 :Then :Disp "QUIT?" |
When N is divisible by C, the program asks if you would like to quit or to continue. |
:Input T | If T=1, the program stops. If T=0, it continues. |
:End | End “If… Then” |
:End | End “While not(T)” |
Outcome: | Its Location I: |
Number of occurrences: |
Probability (percent): |
Cumulative probability: |
LP*: |
R R R |
1 |
LR(1) |
5% |
.05 |
0 |
R R G |
2 |
LR(2) |
15% |
.20 |
.05 |
R R Y |
3 |
LR(3) |
30% |
.50 |
.20 |
R Y G |
4 |
LR(4) |
30% |
.80 |
.50 |
R Y Y |
5 |
LR(5) |
15% |
.95 |
.80 |
R Y G |
6 |
LR(6) |
5% |
1 |
.95 |
*LP is the list of the 6 cumulative probabilities, shifted by one.
Return
to Drawing Marbles Index