
130
The expression
INT(RANDOM*6+1)
will
simulate one roll of the die. This means that
MAKELIST(INT(RANDOM*6+1),X,1,500,1)
will simulate 500 rolls of a normal die.
We therefore need only store the
resulting list into a Statistics aplet
column to analyze and graph it. This
is shown in the series of screen shots
to the right.
To simulate the adding of two six sided dice, use the similar expression
MAKELIST(INT(RANDOM*6+1)+INT(RANDOM*6+1),X,1,500,1)
Simulating Random Variables
It is occasionally handy to be able to simulate a set of observations on
random variables of various sorts. This can also be done using the
MATH
menu function
MAKELIST
. (See previous page for syntax. Covered in more
detail on page 266)
Example 1: Simulate 100 observations on a U[0,1] r.v. to be stored in
C2
.
In the
HOME
view type:
MAKELIST(RANDOM,X,1,100,1)
C2
Note: 1. The symbol is one of the screen keys in the
HOME
view,
appearing
as and read as ‘store’.
2. The
X
is only a dummy variable here to count off the values.
Example 2: Simulate 50 observations on a discrete uniform r.v. U[3,7]
In
HOME
type:
MAKELIST(INT(5*3),X,1,50,1)
C2
Example 3: Simulate 50 obs. on a Binomial r.v. with n = 20 and p = 0.75.
In
HOME
type:
MAKELIST(
Σ
(I=1,20,RANDOM<0
.
75),X,1,50,1)
C2
Note: The
Σ
and the = are both on the keyboard. This will be a
relatively slow calculation because it involves evaluating 1000
random numbers.