Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Random Number Generator In PL/SQL

Re: Random Number Generator In PL/SQL

From: Michael Nolan <nolan_at_inetnebr.com>
Date: 1997/08/22
Message-ID: <5tkene$g5c$1@falcon.inetnebr.com>#1/1

Chuck Erickson <beachst.cerick01_at_eds.com> writes:

>Can anyone provide further information on the origin of these and on the
>applicability or soundness of these generators. Has anyone done any
>type of statistical analysis validating either one. Any comments would
>be appreciated.

The technical validity of pseudorandom number generators is probably beyond the scope of this newsgroup, and anyone really interested in it should check a textbook on the subject. (Knuth's "Art of Computer Programming", volume 2, has an excellent discussion on pseudorandom number generator techniques, for example.)

I have my own PL/SQL pseudorandom number generator function, and I use the RANDOM = MOD(SEED * A + B, C) generation technique. It's been too many years since I've studied the subject, but as I recall as long as A, B, and C are at least relatively prime to each other, then the numbers generated are fairly well distributed and the period of the function is C, meaning when RANDOM becomes SEED for the next iteration then all numbers between 0 and C-1 are generated before the sequence starts repeating itself.w

I use 10141357, 20231611, and 38142517 for A, B, and C, respectively. (These are all prime numbers, and as I recall I tested to make sure that these numbers were within Oracle's computational range when I wrote the function.)

There are undoubtably disadvantages with this technique, but I've long since forgotten what they might be.

--
Mike Nolan
nolan_at_inetnebr.com
Received on Fri Aug 22 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US