EasyManua.ls Logo

HP HP-20S - Sample Program: Random Number Generator

HP HP-20S
132 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Sample
Program:
Random
Number
Generator
The
following
program
generates
random
numbers
in
the
range
0
<
r;
<
1.
The
program
uses
a
starting
value
between
0
and
1.
For
a
different
sequence
of
random
numbers,
use
a
different
starting
value.*
Keys:
Display:
Description:
)
Enters
Program
mode.
(]
00-
Clears
program
mem-
ory.
(Skip
this
step
to
leave
programs
intact.)
(]
A
01-
61 41
A
Names
program
”A”.
0
02-
22
0
Get
7;.
03-
55
Multiplies..
..
9
04-
9
9
05-
9
7
06-
7
...
by
997.
(=]
07-
74
Equals
9977;.
()
08-
61
45
tiv1
=
FP
(997r)).
(sT0]0
09-
21
0
Saves
71,
;.
*
The
program
uses
the
algorithm:
r;,;
=
FP
(997r;),
where
r;
is
a
starting
value
between
0
and
1
(for
example,
0.5284163).
The
random
number
generator
passes
the
chi-square
fre-
quency
tests
for
uniformity,
and
the
serial
and
run
tests
for
randomness.
The
most
significant
digits
are
more
random
than
the
least
significant
digits.
If
the
starting
value
is
between
0
and
1,
and
if
the
starting
value
x
107
is
not
divisible
by
2
or
5,
then
the
generator
produces
500,000
different
random
numbers
before
repeating.
6:
Programming
75

Table of Contents

Related product manuals