-21
$\begingroup$

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}]];
SeedRandom[seed0];

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

$\endgroup$
5
  • 1
    $\begingroup$ What's wrong with the default seed ("the time of day and certain attributes of the current Mathematica session")? $\endgroup$ Mar 7, 2012 at 17:53
  • 14
    $\begingroup$ @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. $\endgroup$
    – Sasha
    Mar 7, 2012 at 18:05
  • $\begingroup$ Does anyone have an opinion on the methods offered by SeedRandom? $\endgroup$
    – Sinistar
    Mar 7, 2012 at 18:10
  • 2
    $\begingroup$ "MersenneTwister" Mersenne twister shift register generator "MKL" Intel MKL generator (Intel-based systems) "Rule30CA" Wolfram Rule 30 generator $\endgroup$
    – Sinistar
    Mar 7, 2012 at 18:10
  • $\begingroup$ @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. $\endgroup$
    – Mr.Wizard
    Mar 20, 2014 at 19:32

4 Answers 4

15
$\begingroup$

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).

$\endgroup$
14
$\begingroup$

Here is how you can get a truly random number:

http://www.idquantique.com/true-random-number-generator/products-overview.html

Quantum mechanics.

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

http://www.random.org/

But is atmospheric noise, really random enough for you?

$\endgroup$
9
$\begingroup$

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]
Dynamic[updateMouse[MousePosition[]]]
Pause[10];
Clear[updateMouse]

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

$\endgroup$
6
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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