Re: Help!! Random Integer Generator Algorithm



On Mon, 16 Jan 2006 22:30:20 -0800, Klein wrote:

> Currently, I need a generator of random integer between 0 and 36. And this
> generator cannot contain any float operation. I tried srand48+lrand48 in
> GNU C Library. I get a random integer each time I invoke lrand48 and make
> the result mod 37. I try this 17804294 times. but the result is not fine.
> For example, there are 479571 "7" but 482212 "3".

I suspect that the problem is in srand48 and lrand48, not in the mod.

There are links to several pseudo-random number generators at
http://www.cs.sunysb.edu/~algorith/files/random-numbers.shtml

There are a few more at
http://www.nist.gov/dads/HTML/pseudorandomNumberGen.html

-paul-
--
Paul E. Black (p.black@xxxxxxx)

.



Relevant Pages

  • Re: Simple Random Integer Generation
    ... I simply need a function that will generate a random integer between say 1 and 999. ... Its an instance of the RandomGen class just in case ... anyone wants to implement a different random number generator. ... its just like any other language it has to do it in the IO monad. ...
    (comp.lang.functional)
  • Better use of random number genator bits?
    ... If I have a random number generator creating random binary digits, ... and I want to construct a random integer between 0 and say 40, ... Also another way we know is to produce a 226 bit random number but the math ...
    (sci.math)
  • Re: random data in structure - checking for no double values
    ... (it is in fact a generator for numbers like in a lotto), ... is there a possibility to circumvent packing an array with the values ... void KnuthShuffle(int n, int* deck) ... generating a random integer between 1 and 45 is better (if ...
    (comp.lang.c)
  • Re: Anyone have any ideas on this one.....
    ... generator with for instance srand)). ... fact it is better to generate random integer from set ... to be zeroed first of course. ... results using two nested for loops. ...
    (comp.lang.c)
  • Help!! Random Integer Generator Algorithm
    ... I need a generator of random integer between 0 and 36. ... this generator cannot contain any float operation. ... srand48+lrand48 in GNU C Library. ...
    (comp.theory)