Sunday, April 12, 2020

TI-80 and TI-84 Plus CE: Drawing a Bag of Two Kinds of Items

TI-80 and TI-84 Plus CE:  Drawing a Bag of Two Kinds of Items

Introduction




The program BINDRAW has a participant draw from a population made of two type of objects, A and B.  Think of a bag with green marbles (A) and red marbles (B).  You are given the number of draws and you need to calculate the chance you draw a certain combination, such as 3-draws of order A, A, B or A, B, A.

POP A:  number of A balls in the bag

POP B:  number of B balls in the bag

The ^-1 is the inverse function [ x^-1 ]

TI-80 Program  BINDRAW (161 bytes)

The TI-80 Program of BINDRAW is a simple version, which calculates a single probability.

INPUT "POP A?",A
INPUT "POP B?",B
A + B → T
DISP "TOTAL:",T
INPUT "NO OF DRAWS?",D
(T nPr D)^-1 → P
FOR(I,1,D)
CLRHOME
DISP "DRAW ",I,"1. A 2. B"
INPUT J
IF J = 1
THEN
P * A → P
A - 1 → A
ELSE
P * B → B
B - 1 → B
END
END
DISP "PROB:",P

TI-84 Plus CE Program BINDRAW (374 bytes)

The TI-84 Plus CE version of BINDRAW expands on the simple version.  After calculating a single probability: you get a menu of the following options.

ADD TO MEM:  Add the probability to memory.  The memory register is the cumulative probability.  The cumulative probability is displayed.

CLEAR MEM:  Reset the cumulative probability to zero.

NEW DRAW:  Start a new draw.  The cumulative probability remains intact.

NEW PROB:   Starts a new problem.  The cumulative probability resets to zero.

QUIT:  End the program.

"2020-02-29 EWS"
Lbl 0
Input "POP A?",N
Input "POP B?",M
N + M → T
Disp "TOTAL",T
0 → S
Input "NO OF DRAWS?",D
Lbl 1
N → A 
M → B
(T nPr D)^-1 → P 
" " → Str0
For(I, 1, D)
Disp "DRAW " + toString(I), "HIST " + Str0, "1. A 2. B"
Input J
If J = 1
Then
P * A → P
A - 1 → A
Str0 + "A" → Str0
Else
P * B → P
B - 1 → B
Str0 + "B" → Str0
End
End
Disp "PROB"
Pause P
Lbl 2
Menu("MENU", "ADD TO MEM", 3, "CLEAR MEM", 4, "NEW DRAW", 1, 
"NEW PROB", 0, "QUIT", 5)
Lbl 3
P + S → S
Disp "MEM"
Pause S
Goto 2
Lbl 4
0 → S
Disp "MEM CLEARED"
Pause
Goto 2
Lbl 5

You can download the TI-84 Plus CE program here:
https://drive.google.com/open?id=1HBpv5rNN6kA-__MTKoc3RJtMAgqyF1w4

Example

The bag has 5 balls labeled "A" and 3 balls labeled "B".  What is the probability of either drawing 3 "A" balls in a row or drawing 3 "B" balls out of the bag?

Prompts:
POP A?  5
POP B?  3
(Total = 8)
DRAWS? 3

Three "A": choose option 1 three times in a row
Probability:  0.1785714286

Three "B": choose option 2 three times in a row
Probability:  0.0178571429

Cumulative Probability:  0.1964285715

Blog turns 9 on the 16th 

This is the last blog entry of the 9th year of my calculator and math blog as this blog turns 9 on April 16, 2020.  Thank you to everyone and all your support!  See year when we start Year 10 (!) on the 17th. 


Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.