Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I cooked up this simple bit of code in hopes to exceed pseudorandom number generation maybe touch the face of true randomization:

    For[i = 1, i < 65, i++,
  seed0 = RandomInteger[{1, 22957480^3}];
  SeedRandom[seed0]; seed0 = RandomInteger[{1, 22957480^3}]];

I am concerned over the default seed value though. Anyone have a better way to generate randomness?

share|improve this question
What's wrong with the default seed ("the time of day and certain attributes of the current Mathematica session")? – István Zachar Mar 7 '12 at 17:53
@Sinistar What you do does not perform any better that default initialization. In fact, there is a 1-1 mapping from the default seed to the seed you propose. Thus you introduced no additional randomness. – Sasha Mar 7 '12 at 18:05
Does anyone have an opinion on the methods offered by SeedRandom? – Sinistar Mar 7 '12 at 18:10
"MersenneTwister" Mersenne twister shift register generator "MKL" Intel MKL generator (Intel-based systems) "Rule30CA" Wolfram Rule 30 generator – Sinistar Mar 7 '12 at 18:10
@Sinistar I read your flag. Moderators cannot control how people vote, so appealing to us not to down-vote won't help. (Incidentally one of the two up-votes is mine; I thought it was a good question because of the discussion it lead to.) I suggest you add a note to the top of your question kindly asking people to stop down-voting. – Mr.Wizard Mar 20 '14 at 19:32

You cannot, by principle, get true randomness through a deterministic algorithm, no matter how sophisticated. If you need true random numbers, you'll have to collect some physical randomness. I don't know about an OS-independent way to do that, but on Linux, the pseudo-file /dev/random collects entropy from various sources.

Of course, unless you are implementing cryptography, you'll most likely not really need true randomness (and even there you generally only need it to seed the cryptographically secure pseudo-random number generator, unless you are generating an one-time pad).

share|improve this answer

Here is how you can get a truly random number:

Quantum mechanics.

You could also use which provides random numbers based on atmospheric noise:

But is atmospheric noise, really random enough for you?

share|improve this answer

To add to what @celtschk said, I've seen programs like TrueCrypt use mouse movement entropy to seed a (pseudo?)-random number generator. To get mouse input in MMA for 10 seconds, you could use something like:

mouse = {};
updateMouse[pos_] := AppendTo[mouse, pos]

I don't know much about cryptography and creating good entropy seeds, but this is the start of an approach that could be used.

share|improve this answer

I believe Mathematica is robust enough for writing a driver and the necessary image recognition software for this machine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.