Suppose you repeatedly draw two tokens out of seven from a bag. The colors of the seven tokens are as follows: four are blue, two are green, and 1 is yellow.
When you are drawing 2 tokens from the bag you have six ways to draw 2 blues, 8 ways to draw a blue and a green, 4 ways to draw a blue and a yellow, 2 ways to draw a green and a yellow, and one way to draw two greens.
So there are 21 possible ways (6 + 8 + 4 + 2 + 1) that 2 tokens can be drawn from 7, and they result in only 5 different combinations of colors, BB, BG, BY, GY, and GG. The probability of each of the five combinations are given in the 4th column of the table below the program and they are: 6/21, 8/21, 4/21, 2/21, 1/21.
(See https://www.math.nmsu.edu/%7Ebreakingaway/Statistics/Marbles/Activity2.html for this derivation.)
The program STAT1 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=5.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 five 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:STAT1
:5→dim(LR)  There are 5 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,6/21,14/21,18/21,20/21}→LP  The list of cumulative probabilities for the 5 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 five draws is made. 
:sum(Q≥LP)
→I 
I is the location of one out of five 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}→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*: 
B B 
1 
LR(1) 
6/21 = 29% 
6/21 
0 
B G 
2 
LR(2) 
8/21 = 38% 
14/21 
6/21 
B Y 
3 
LR(3) 
4/21 = 19% 
18/21 
14/21 
G Y 
4 
LR(4) 
2/21 = 9.5% 
20/21 
18/21 
G G 
5 
LR(5) 
1/21 = 5% 
21/21 
20/21 
*LP is the list of the 5 cumulative probabilities, shifted by one.
Return to Drawing Marbles Index