Help!! Random Integer Generator Algorithm



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".

What should I do? Does "mod" operation cause this result?

Thanks!

.



Relevant Pages

  • Re: Help!! Random Integer Generator Algorithm
    ... I need a generator of random integer between 0 and 36. ... > generator cannot contain any float operation. ... I get a random integer each time I invoke lrand48 and make ...
    (comp.theory)
  • 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)

Loading