Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Select random rows?
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:
(The text below borrowed/pilfered from "Numerical Recipes for C++", www.nr.com)
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
--
"Some days you're the pigeon, and some days you're the statue." Received on Tue Nov 09 1999 - 04:04:04 CST
![]() |
![]() |