Simulation of a normal die
Similarly 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 the previous page for the syntax of
MAKELIST
. It is also covered in more detail on page 190)
Example 1:
Simulate 100 observations on a Uniform[0,1] random variable to be stored in
C2
.
In the
HOME
view type:
MAKELIST(RANDOM,X,1,100,1) C2
symbol is one of the screen keys in the
HOME
view,
appearing
as
Note:
1. The
and read as ‘store’.
2. The
X
is simply a dummy variable here to count off the values.
Example 2:
Simulate 50 observations on a discrete uniform[3,7] random variable
In
HOME
type:
MAKELIST(INT(5*3),X,1,50,1) C2
Example 3:
Simulate 50 observations on a Binomial random variable 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.
121