35 - 44 Simulation Random Numbers
35 - 44 Simulation Random Numbers
Random numbers
Simulation
Practice using random numbers for simulations
hp calculators
When a coin is flipped, the probability of heads is 0.5 and of tails also 0.5. Let the decimal range of 0 <
random number < 0.5 equate to observing a "heads." The decimal range of 0.5 <= random number <1 will
equate to a tails. Store the initial seed and then generate the four random numbers.
In RPN mode:
h
In algebraic mode: h
In RPN mode, press {j. In algebraic mode: {j
Figure 1
Figure 2
Figure 3
hp calculators
-2-
hp calculators
Figure 4
Answer:
The first three random numbers are in the range 0.5 <= random number <1, and therefore equate to the
result "heads." The fourth random number is in the range 0 <= random number < 0.5, and is therefore a
result of "tails." Figures 1 through 4 show the display assuming algebraic mode.
Example 2: Nelson's Newstand sells newspapers and has experienced demand for newspapers as follows over the last
50 days: 10 newspapers on 5 of the days; 15 newspapers on 20 of the days; 20 newspapers on 15 of the
days; and 25 newspapers on 10 of the days. Using random numbers and an initial seed of 0.234567,
simulate demand for the next 4 days.
Solution:
The first step will be to translate the past demand into ranges for our random numbers for the simulation.
Out of past 50 days, demand was 10 on 5 of these days, or 10% of the time. Out of the past 50 days,
demand was 15 on 20 of these days, or 40% of the time. Out of the past 50 days, demand was 20 on 15 of
these days, or 30% of the time. Finally, out of the past 50 days, demand was 25 on 10 of the days, or 20%
of the time. This information can be summarized in a table as shown below.
Demand
10
15
20
25
Probability
0.1
0.4
0.3
0.2
Next, we need to assign a range for each level of demand that corresponds to the relative probability for
that demand. It is this range that will be used to classify each random number as a specific simulated
demand.
Demand
10
15
20
25
Probability
0.1
0.4
0.3
0.2
Range
0.0 < random number <= 0.1
0.1 < random number <= 0.5
0.5 < random number <= 0.8
0.8 < random number < 1.0
Note that each range corresponds to the probability of each outcome (the range between 0.1 and 0.5 is
40% of the possible outcomes of the random numbers and therefore reflects the 40% chance that a
demand of 15 will occur). Store the initial seed and then generate the five random numbers. Evaluate each
random number as it is generated.
In RPN mode:
h
In algebraic mode: h
hp calculators
-3-
hp calculators
Figure 5
This corresponds to a demand of 20 newspapers. In RPN mode, press {j. In algebraic mode:
{j
Figure 6
This corresponds to a demand of 15 newspapers. In RPN mode, press {j. In algebraic mode:
{j
Figure 7
This corresponds to a demand of 20 newspapers. In RPN mode, press {j. In algebraic mode:
{j
Figure 8
This corresponds to a demand of 20 newspapers. In RPN mode, press {j. In algebraic mode:
{j
Figure 9
The results were demands of 20, 15, 20, and 20 newspapers. If the simulation were carried out for a longer
period (which could be done by writing a program), other levels of demand would be generated. Figures 5
through 9 show the display assuming algebraic mode.
hp calculators
When a die is rolled, the result is equally likely to be a 1, 2, 3, 4, 5, or 6. Since the HP 35s random numbers
are decimal numbers, it will be necessary to transform them into integers between 1 and 6. Since the
-4-
hp calculators
Figure 10
In RPN mode:
In algebraic mode:
{jyg
g {jy
Figure 11
In RPN mode:
In algebraic mode:
{jyg
g {jy
Figure 12
Answer:
hp calculators
The value of the first die was a 4 and the second was a 3, for a total on the two dice of 7. Figures 10
through 12 show the display assuming algebraic mode. Note: In algebraic mode, to generate another
random dice roll, it is much quicker to press and then . This will re-evaluate the previous
command line.
-5-