Jump to content

The Production of a Random Number!


mehran

Recommended Posts

Hi everybody,

We all know that we can have random numbers by pressing #RAN or #RND button in calculators and there is such a command in computer programming languages that produces a random number.

It's always been a question for me that how does a computer or a calc generate random numbers? Does it have a certain algorithm or sth?

Link to comment
Share on other sites

I saw very ingenious "real" random number generator implementation in example code for IAR startup kit (microcontroller used for testing and evaluation purposes). It was done by applying MD5 hash algorithm to the unfiltered value of the analog sensor (which is constantly changing due to electronic noise) - remarkably simple and efficient.

 

Also, some cryptographic software requires the user to make "random" mouse movements, to generate "real" random sequences.

Link to comment
Share on other sites

Dear Cap'n Refsmmat and vordhosbn, thx for your answers. They were useful.

I've read some where that a random number can be produced by the current date and time. Is that possible? I don't know, but I think this way has problems.

Link to comment
Share on other sites

Many people will "seed" a pseudorandom number generator with the current time as the initial value. This is because some generators would otherwise use the same seed with each use, causing the sequence of random numbers they generate to be the same each time.

 

It's not an optimal solution, but it's better than what it was designed to fix. There are better options, like gathering randomness from system events. Look into how /dev/random works on Linux and BSD systems.

Link to comment
Share on other sites

and an even better method than using the time as a seed is to use a true random number as a seed.

 

most computers will generate true random numbers but only very very slowly. a few bytes per second. not particularly useful if you need thousands of random numbers but it can be used to seed a pseudorandom number generator and then your off.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.