General information
Category:
Coding, syntax & commands
>Hello all,
>
>I need to generate random numbers. I need to get all numbers from 1 to 75 but randomly. I generated those but with a delay. Everything looked good when I generated those numbers with a delay of around 6 seconds. This means that numbers looked realy random. For example numbers generated looked like 25, 47, 12, 59 and so on.
>
>A delay of six seconds between generated numbers was not enough. I had to increase the delay to 8 seconds. That's when the weirdest thing happened. The generated numbers didn't really look random. For example generated numbers looked like 23, 34, 45,46,47,48,49,50, 51, 30,31,32,33,34,45.
>
>So I assume that the delay is the problem.
>
>My solution to that weird problem. I generate all the random numbers without a delay between each generated number.
>Then I get all the numbers in the order they were generated each 8 seconds.
>
>Can anybody explain me why there seems to be a problem with random numbers and a delay?
There's no need for a delay in generation random numbers. However, the whole notion of random numbers is that there will be repeats. You need to code assuming it happens and rejecting the repeats.
FWIW, one of the tests of how random a random number generator is is how many numbers you have to generate to get all the numbers in a particular sequence. If the sequence has n values, you definitely don't expect n random numbers to get one of each. The test is called the Coupon Collectors Test.
Tamar
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only