0% found this document useful (0 votes)
65 views5 pages

35 - 44 Simulation Random Numbers

The document discusses using random numbers for simulations on the HP 35s calculator. It provides examples of simulating coin flips, newspaper sales demand, and rolling dice. For simulations, an initial seed number is entered to start the random number generation. Random numbers between 0 and 1 are then produced sequentially and mapped to simulation outcomes based on assigned probability ranges.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views5 pages

35 - 44 Simulation Random Numbers

The document discusses using random numbers for simulations on the HP 35s calculator. It provides examples of simulating coin flips, newspaper sales demand, and rolling dice. For simulations, an initial seed number is entered to start the random number generation. Random numbers between 0 and 1 are then produced sequentially and mapped to simulation outcomes based on assigned probability ranges.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

hp calculators

HP 35s Using random numbers for simulations

Random numbers
Simulation
Practice using random numbers for simulations

hp calculators

HP 35s Using random numbers for simulations


Random numbers
Random numbers have uses as varied as games and stock market simulations. On the HP 35s, generating random
numbers involves providing a starting decimal seed to the calculator using the h function. Random numbers
between 0 and 1 are then generated sequentially using the {j function.
A different series of random numbers will be generated from each decimal number used as an initial seed. Using the
same initial seed will result in the same series of random numbers.
Simulation
A useful application of random numbers is to simulate complex processes that involve the element of chance. These
simulations can be as easy as simulating the flip of a coin or can be quite elaborate. The examples below are far from
exhaustive, but provide an illustration of how random numbers can be used on the HP 35s.
Practice solving problems angles and times
Example 1: Simulate flipping a coin four times. Use a starting seed of 0.123456.
Solution:

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

In RPN mode, press {j. In algebraic mode: {j

Figure 2

In RPN mode, press {j. In algebraic mode: {j

Figure 3

In RPN mode, press {j. In algebraic mode: {j

hp calculators

-2-

HP 35s Using random numbers for simulations - Version 1.0

hp calculators

HP 35s Using random numbers for simulations

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 35s Using random numbers for simulations - Version 1.0

hp calculators

HP 35s Using random numbers for simulations


In RPN or algebraic mode: {j

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

This corresponds to a demand of 20 newspapers.


Answer:

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.

Example 3: Simulate rolling 2 dice. Use a starting seed of 0.345678


Solution:

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 35s Using random numbers for simulations - Version 1.0

hp calculators

HP 35s Using random numbers for simulations


lowest possible valid value of rolling a die is 1, the process to transform a decimal random number into a
value between 1 and 6 will be:
Result = The integer value of ( the random number x 6 plus 1 )
It is necessary to multiply the decimal random number generated by 6, add 1 and take the integer value of
the result. Since two die are to be rolled, this will be done two times. Store the initial seed and then
generate the first random number.
In RPN mode:
h
In algebraic mode: h


Figure 10

In RPN mode:
In algebraic mode:

{jy g
g {jy

Figure 11

In RPN mode:
In algebraic mode:

{jy g
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-

HP 35s Using random numbers for simulations - Version 1.0

You might also like