Simulation Of Sampling Without Replacement - Texas Instruments TI-89 Manual Book

Ti ti-89: user guide
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Simulation of Sampling without Replacement

Sampling-without-
Replacement
Function
Sampling without
Replacement
This activity simulates drawing different colored balls from an urn
without replacing them. Detailed information about the steps used
in this example can be found in Chapter 17: Programming.
In the Program Editor, define
called with two parameters. The first parameter is a list where each
element is the number of balls of a certain color. The second
parameter is the number of balls to select. This function returns a list
where each element is the number of balls of each color that were
selected.
:drawball(urnlist,drawnum)
:Func
:Local templist,drawlist,colordim,
numballs,i,pick,urncum,j
:If drawnum>sum(urnlist)
:Return "too few balls"
:dim(urnlist)! colordim
:urnlist! templist
:newlist(colordim)! drawlist
:For i,1,drawnum,1
:sum(templist)! numballs
:rand(numballs)! pick
:For j,1,colordim,1
:cumSum(templist)! urncum
(continued in next column)
Suppose an urn contains n1 balls of a color, n2 balls of a second
color, n3 balls of a third color, etc. Simulate drawing balls without
replacing them.
1. Enter a random seed using the
command.
RandSeed
2. Assuming the urn contains 10
red balls and 25 white balls,
simulate picking 5 balls at
random from the urn without
replacement. Enter
drawball({10,25},5)
.
Result: 2 red balls and 3 white
balls.
drawball()
as a function that can be
:If pick  urncum[j] Then
:drawlist[j]+1! drawlist[j]
:templist[j]ì 1! templist[j]
:Exit
:EndIf
:EndFor
:EndFor
:Return drawlist
:EndFunc
Chapter 23: Activities
407

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents