in reply to Re^6: How likely is rand() to repeat?
in thread How likely is rand() to repeat?
Only that from any given starting point, the non-repeating sequence could be any permutation of those 24 permutations.No. With a seed/state of 2 bits, for any given implementation, and any given starting point, only 4 out of the 24 permutation are possible. Think about it. You're working on a deterministic machine. You have only 4 different begin states. How can you have more than 4 end states?
If you think I'm wrong, show an algorithm that proves otherwise. Given a 2-bit state, that shouldn't be overly complicated.
That's the wrong question. When generating the OPs 25-char sequences, you don't re-seed before starting each new sequence. You seed (implicitely) once and then follow that sequence until you have enough.Eh, no, it's the right question. As you immediately say after stating "it's the wrong question", a sequence is produced. One that isn't reseeded. So, the question is indeed, "how many different sequences can be produced".
Therefore the upper bound is the length of the non-repeating sequence (the period) the prng can generate. (4.31e+6001 in the Mersenne Twister).No, it's not.
Here's another generator, with the same period as the Mersenne Twister, in pseudo code:
It's a simple generator, but produces numbers in the range 0 .. 232-1, and has a sequence length of 219937-1 before it repeats itself. It requires an internal state of about 19937 bits, but has no seed (0 bits).use bigint; my $state = 0; sub rand { $state = ($state + 1) % (2 ** 19937 - 1); $state & 0xFFFFFFFF; }
So, I claim, on each run of the program that uses the above implementation of random, you get one of 20 == 1 different sequences.
Now, you may have a point if the OP was generating all the passwords he may ever require in his life, in a single run of the program. Then the number of different produced strings depends on the size of the state that the generator keeps. Which, for a typical PRNG is 32, 48 or 64 bits. For MT19937, the internal state is 19968 bits (smallest multiple of 32 greater than 19937). You'd need a seed of that size if you want to carry this information over to different runs of the program.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: How likely is rand() to repeat?
by BrowserUk (Patriarch) on Mar 09, 2012 at 11:50 UTC | |
by JavaFan (Canon) on Mar 09, 2012 at 14:02 UTC | |
by BrowserUk (Patriarch) on Mar 09, 2012 at 16:46 UTC | |
by JavaFan (Canon) on Mar 09, 2012 at 17:37 UTC | |
by BrowserUk (Patriarch) on Mar 09, 2012 at 17:52 UTC | |
|