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: Select random rows?

Re: Select random rows?

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Tue, 09 Nov 1999 18:04:04 +0800
Message-ID: <3827F194.7471@yahoo.com>


fumi wrote:
>
> Connor McDonald <connor_mcdonald_at_yahoo.com> wrote in message news:3826AB3C.1C7F_at_yahoo.com...
> >
> > Sorry - I should have added
> >
> > my random function is a variant on the linear congruence algorithm so
> > that no rows will be repeated...
> >
> > The 500 can be replaced with a number more than the ceiling for the
> > table - I just chose that as an example
>
> Theoretically, if your random function returns a integer between 0 and, say, 499,
> there is NO ways to assure the function values will not be repeated,
> or, it can NOT be a random function.

Yes, but practically, all random generators give a pseudo-random sequence of numbers. The linear congruence one (which is very common amongst most 3GL's) is a "nice" one since you can "tweak" the generator so that:

  1. you don't get repeated values
  2. you can reproduce the "random" list at will

(The text below borrowed/pilfered from "Numerical Recipes for C++", www.nr.com)



"System-supplied rand()'s are almost always linear congruential generators, which generate a sequence of integers I1, I2, I2, ..., each between 0 and (m-1) define by the recurrence relation:

I(j+1) = aI(j) + c ( mod m)

Here m is called the modulus, and a and c are positive integers called the multiplier and increment respectively. The recurrence will eventually repeat itself, with a period that obviosuly no greater than m. If m, a and c are properly chosen, typically where m is a suitably large prime, then the period is of maximal length, ie, of length m. In that case, all possible integers between 0 and m-1 will occur, making any initial seed I(0) as good as another"


Regards
Connor
--



Connor McDonald
"These views mine, no-one elses etc etc" connor_mcdonald_at_yahoo.com

"Some days you're the pigeon, and some days you're the statue." Received on Tue Nov 09 1999 - 04:04:04 CST

Original text of this message

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