Generating unique random integers 
Author Message
 Generating unique random integers

Hi,
    I would like an efficient algorithm to generate unique random integers.
Can someone please post such algorithm, or suggest a good reference?
Thanx in advance,
--MJ


Sat, 14 Jul 2001 03:00:00 GMT  
 Generating unique random integers
    Check Knuth's 2nd Volumn.
    Jacques
Quote:

>Hi,
>    I would like an efficient algorithm to generate unique random integers.
>Can someone please post such algorithm, or suggest a good reference?
>Thanx in advance,
>--MJ



Sun, 15 Jul 2001 03:00:00 GMT  
 Generating unique random integers
There is an algorithm in _Numerical Recipes in C_
by Press et al.  They even do some bragging about how good it is,
in the form of offering a reward to anybody who shows it is flawed
within certain parameters. It's not too difficult to wrap their code
in a class to give you a random number generator object.

I think that this nummies book is even on the web someplace.
Try searching at Alta Vista for the title.
--
Dan Evens
(Standard disclaimers etc. No spam please.)



Quote:
> Hi,
>     I would like an efficient algorithm to generate unique random
integers.
> Can someone please post such algorithm, or suggest a good reference?



Sun, 15 Jul 2001 03:00:00 GMT  
 Generating unique random integers

Quote:

> There is an algorithm in _Numerical Recipes in C_

Note that while Numerical Recipes in C is a pretty good
book on the computational parts.  Their examples aren't
usually very efficient and some even violate the C standard.


Sun, 15 Jul 2001 03:00:00 GMT  
 Generating unique random integers
    Check:

http://ourworld.compuserve.com/homepages/sam_blackburn/CRandomNumberG...
r.htm
    Jacques

Quote:


>> There is an algorithm in _Numerical Recipes in C_

>Note that while Numerical Recipes in C is a pretty good
>book on the computational parts.  Their examples aren't
>usually very efficient and some even violate the C standard.



Sun, 15 Jul 2001 03:00:00 GMT  
 Generating unique random integers
This url fails!

Quote:

>    Check:

>http://ourworld.compuserve.com/homepages/sam_blackburn/CRandomNumberG
enerato
>r.htm
>    Jacques



Sun, 15 Jul 2001 03:00:00 GMT  
 Generating unique random integers


Quote:

> > There is an algorithm in _Numerical Recipes in C_

> Note that while Numerical Recipes in C is a pretty good
> book on the computational parts.  Their examples aren't
> usually very efficient and some even violate the C standard.

That is why, in the part you cut out, I said that it is easy
to wrap their algorithm in a class.  Yes they do some stuff
that is not very elegant and looks foreign to a C++ coder.
But it's nothing an old C hacker would be surprised by.
(Might not like the flavour.  They do things like a kludge to
get around starting arrays at zero.)

And the important part is the algorithm anyway. (And in
this particular case some "magic numbers" that have been
chosen to have certain special relationships.)  It's pretty
rare that I use nummies code from any source without
modifying it pretty heavily.  (Nummies libraries are, of
course, a different matter.)

And speaking  of efficiency:  In a random number generator,
it is unlikely that efficiency will be all that critical. The actual
generation of the random number is unlikely to be a big part
of the total computation involved.  What is likely to be most
important is the quality of the number in terms of things like
how long the period is, how well the sequence obeys tests
of statistics, how hard it is to predict the next number given
a sequence, and so on.  If the algorithm is good on these
scores, it is unlikely for most applications that absolute top
efficiency will be critical.

But if it is, then a good nummies book will give refs to the
more advanced literature.  And Press et al. do this.
And if you are writing an application that needs this sort
of high performance, you likely already have many of
these references and have forgotten more about nummies
than I will ever know.
--
Dan Evens
(Standard disclaimers etc. No spam please.)



Sun, 15 Jul 2001 03:00:00 GMT  
 Generating unique random integers
It works for me, but I had to paste the url back together (it got split
across multiple lines).
Quote:

> This url fails!


> >    Check:

> >http://ourworld.compuserve.com/homepages/sam_blackburn/CRandomNumberG
> enerato
> >r.htm
> >    Jacques



Sun, 15 Jul 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Generating Unique random integers

2. generate unique random string or GUID

3. Any good methods for generating pseudo random integer?

4. Generating a Random Integer Within a Range

5. How to generate random integer number??

6. Unique Random Numbers

7. Unique no generating

8. Generating unique 3 digit number

9. How to generate a machine unique ID

10. Generating Unique 8 char string

11. Representing a string as a unique integer.

12. Generating unique id#

 

 
Powered by phpBB® Forum Software