Oracle® OLAP DML Reference 10g Release 1 (10.1) Part Number B10339-02

## RANDOM

The RANDOM function produces a number that is randomly distributed between specified low and high boundaries. Randomly generated numbers are useful when building and duplicating tests of applications. They are especially useful for simulation and forecasting applications.

Return Value

DECIMAL

Syntax

RANDOM([lowbound] [highbound])

Arguments

lowbound

A numeric expression that specifies the lower boundary for the random number series. The default is `0`.

highbound

A numeric expression that specifies the upper boundary for the random number series. The default is `1`.

Notes

NA Values

When either lowbound or highbound is `NA`, the RANDOM function produces `NA`.

DECIMAL-to-INTEGER Conversion

When you use the RANDOM function to assign values to an INTEGER variable, RANDOM produces decimal values that are rounded when assigned to the variable.

Reproducing a Random Sequence

To compute the number, RANDOM uses the values of the options RANDOM.SEED.1 and RANDOM.SEED.2, and then changes the values for the next time.

When you want to reproduce the same sequence of random numbers when you are developing and debugging your application programs, set RANDOM.SEED.1 and RANDOM.SEED.2 to some specific values just before using RANDOM. To duplicate the sequence, set these options to the same values just before using RANDOM again. Then changes in the behavior of your programs will be caused by your changes to the programs and not by differing sequences of random numbers.

Creating Seed Values

When you create your own seeds, set both RANDOM.SEED.1 and RANDOM.SEED.2 to odd numbers. This practice enhances the randomness of the numbers that are produced.

Examples

Example 20-1 Producing Random Numbers

This example assigns random numbers between 100 and 200 to a variable called `test`, which is dimensioned by `product`.

```test = RANDOM(100 200)
REPORT test

```

These statements produce a report such as the following.

```PRODUCT           TEST
-------------- ----------
Tents              122.93
Canoes             176.69
Racquets           168.32
Sportswear         150.92
Footwear           187.46
```