Does it toss a coin to get random bit?
Or throw a die to get a random integer from 1 to 6?
Or take a car
Those numbers generated by your computer are not "random" by the true definition of "random". They are pseudorandom - there is an algorithm that generates numbers. Here you can read more about those numbers: http://en.wikipedia.org/wiki/Pseudorandom_number_generator
See Joeys answer. There also exist hardware random generators which use some physical process to produce nouse and which can be plugged into your computer to be used for "true" random number generation (in the mathematical sense, the "true" is superfluous").
Under Unix-likes, such devices could be queried at /dev/random and /dev/urandom.
For an online example, see http://www.random.org/ .
Also make sure to have a look at http://en.wikipedia.org/wiki//dev/random.
This is linux-specific but there is some OS support for "real" randomness: /dev/random
and /dev/urandom
. You read these like normal files.
random
is real randomness gleaned from physical processes such as irregular latencies in the hardware -- it is depleted when you read it and is cryptographically secure.
urandom
is a limitless pseudorandom source which is derived from random
and almost certainly higher quality than your C library PRNG.
Surely human is more random. Compiler (actually, the random module which is compiled by the compiler) only uses some dummy-random (not actually random, just likely) algorithm to generate a random number.
A compiler does absolutely nothing with regards to requiring a random number. A compiler merely makes your code, call some other code which returns a random number. Now the "other code" which calls the random number might be:
In cases (1) and (2), it is mostly a pseudo-random algorithm, and the numbers you get aren't really random. If it is part of a standard library (like cmath or math.h), then one cannot say for sure that the result values are pseudo-random because the standards specify only the definition and not implementation.
EDIT: The library is stdlib.h and it is ALWAYS a psuedo-random number as pointed out by Joey and phresnel. Read comments for details on their answers. I apologize for the error and I agree that I should have known better than to reply on instinct.
Special libraries may be used which may have special implementation of other algorithms, like the Mersenne Twister algorithm. Also, they may be nothing more than drivers of Hardware that can generate random numbers. Hardware random number generators return somewhat "true" random numbers http://en.wikipedia.org/wiki/Hardware_random_number_generator.
Random number algorithms from standard libraries eventually map to system calls on the OS. So, on linux, for example, you may simply be reading from /dev/random
or /dev/urandom
(or you may be doing the same thing in your own code as well).
Also note that, true randomness can be achieved without using dedicated hardware or some dedicated service. /dev/random
and /dev/urandom
provide random numbers, which for all intents and purposes can be considered true.
EDIT: Some special libraries or your own code may even be using a network service for random numbers (many of which provide true random numbers).
Google random number generation: http://en.wikipedia.org/wiki/Random_number_generation
Whist not truly random I would choose a computer to generate a random number any day humans are rubbish at randomness as they behave in a predicitable way
see: http://www.physorg.com/news186174216.html