mehran Posted February 11, 2010 Posted February 11, 2010 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?
Cap'n Refsmmat Posted February 11, 2010 Posted February 11, 2010 This should give you a good introduction to the various ways of making random numbers: http://en.wikipedia.org/wiki/Pseudorandom_number_generator
vordhosbn Posted February 15, 2010 Posted February 15, 2010 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.
mehran Posted February 19, 2010 Author Posted February 19, 2010 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.
Cap'n Refsmmat Posted February 19, 2010 Posted February 19, 2010 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.
insane_alien Posted February 19, 2010 Posted February 19, 2010 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now