Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is random number always unique?

Status
Not open for further replies.

bansalhimanshu

Programmer
Sep 27, 2004
36
US
My understanding is that random numbers are unpredictable. They may or may not repeat however big the size of range of random numbers is. The only condition they satisfy is that you cannot predict what the next number will be irrespective of what the last number was(it can still be the same as the last number).

Your comments on this will be highly appreciated.
 
I'd say that random numbers don't exist, you can use a pseudorandom generator, and its properties will depend on the algorithm used.

Cheers,
Dian
 
I am not talking about implementation of random number generator. What I asked about is the definition of random numbers. By definition my understanding is that random numbers are unpredictable. It can be same as the previous one. Am I right?

Second query - for implementation, is random number unique in java?
 
You're in a Java forum, if you ask for random numbers, the logical answer is how random numbers are generated in Java.

In a computer environment, random numbers don't just exist. The only mechanism avaliable is a pseudorandom generator, usually feed with a seed.

In fact, a random numbers depends on the last n obtained from the generator. I think the answer you're looking for is yes, two consecutive numbers can be the same, but the probability of that should be lower than anyone else.

Wanna know more?


Cheers,
Dian
 
Talking of an abstract random number definition, you're right, bansalhimanshu.

But most random number generators I've seen produce sequences of numbers, which just look unpredictable, but are, if you know the implementation, perfectly determined, and will never give you the same number again.

Fortunately you nearly never use the raw number, because you need a number - let's say from 0-99.
Common practice is, to use a modulu operation, to generate your number from the raw number, and your number might therefore be repeated.

The linux kernel has a random number generator, which uses unpredictable input, like disc access, mouse motion, and keyboard input, to generate really unpredictable results.

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top