Change seed for each generated random number

Suppose you generate random numbers using the seed as the elapsed time in seconds since January 1970, as in the Microsoft library. But you change the seed after every random number generated. This will give a truly random result. Why or why not?

Edit I had one more part of the question. What if I get the seed to be non-deterministic. For a small example, let's say the seed is generated by a pre-existing TRNG (True Random Number Generator). In other words, if I can somehow make the seed non-deterministic, I can create a random sequence, that is, a non-deterministic sequence. Why or why not?

+1


source to share


2 answers


Basically, your technique is simply toggling "randomness" for when you call the random () function: if you call the function at deterministic times (for example, once a second), the results will be deterministic. If you call a function at a random time, the results will be random.

More precisely, it depends on what value you call the seed () function. If you call seed () with deterministic values, the results of the subsequent call to random () will be deterministic.

update (on request):



The software random generator is FULLY deterministic; the sequence of values ​​it produces is exactly what you pass to the original call to seed (). As a result, if you call seed () with a known value, you can predict exactly what series of values ​​you will receive from subsequent calls to random (). If you call seed () with a truly random number, then random () calls will be appropriately random.

(But this begs the question: if you have a random number to pass to seed (), why call random () at all?)

+2


source


True randomness doesn't require seeds. Seeding only applies to PRNGs that are 100% deterministic and not truly random.



So no, using a PRNG in any form will not give true randomness.

+1


source







All Articles