PRDNOR and PRDUNI: Generating Reproducible Random Numbers

How to: |

Available Languages: reporting, Maintain

The PRDNOR and PRDUNI functions generate reproducible random numbers:

- PRDNOR generates
reproducible double-precision random numbers normally distributed
with an arithmetic mean of 0 and a standard deviation of 1.
If PRDNOR generates a large set of numbers, they have the following properties:

- The numbers
lie roughly on a bell curve, as shown in the following figure. The
bell curve is highest at the 0 mark, meaning that there are more
numbers closer to 0 than farther away.
- The average of the numbers is close to 0.
- The numbers can be any size, but most are between 3 and -3.

- The numbers
lie roughly on a bell curve, as shown in the following figure. The
bell curve is highest at the 0 mark, meaning that there are more
numbers closer to 0 than farther away.
- PRDUNI generates reproducible double-precision random numbers uniformly distributed between 0 and 1 (that is, any random number it generates has an equal probability of being anywhere between 0 and 1).

Syntax: How to Generate Reproducible Random Numbers

{PRDNOR|PRDUNI}(seed, output)

where:

- PRDNOR
Generates reproducible double-precision random numbers normally distributed with an arithmetic mean of 0 and a standard deviation of 1.

- PRDUNI
Generates reproducible double-precision random numbers uniformly distributed between 0 and 1.

- seed
Numeric

Is the seed or the field that contains the seed, up to 9 digits. The seed is truncated to an integer.

On z/OS, the numbers do not reproduce.

- output
Double-precision

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Generating Reproducible Random Numbers

PRDNOR assigns random numbers and stores them in RAND. These values are then used to randomly pick five employee records identified by the values in the LAST NAME and FIRST NAME fields. The seed is 40. To produce a different set of numbers, change the seed.

```
DEFINE FILE EMPLOYEE
RAND/D12.2 WITH LAST_NAME = PRDNOR(40, RAND);END
```

TABLE FILE EMPLOYEE PRINT LAST_NAME AND FIRST_NAME BY HIGHEST 5 RAND END

The output is:

RAND LAST_NAME FIRST_NAME ---- --------- ---------- 1.38 STEVENS ALFRED 1.12 MCCOY JOHN .55 SMITH RICHARD .21 JONES DIANE .01 IRVING JOAN

WebFOCUS |