In terms of *output* MT19937 pops out 32-bit uints or 53-bit floats (from batching 2 iterations on 32-bit architecture). MT19937-64 produces 64-bit uints if you have a uniform 64-bit environment.

So it’s impossible to have more than 2^64 iterations without repeating *a number that has been seen before*. It’s easy to measure this by generating 4 billion iterations of MT19937 (or far less depending on the seed) and deduping the results.

The period, of course, refers to the *longest possible* run of numbers, including intra-sequence repeats, before the whole sequence repeats. With a seedable algorithm you don’t necessarily get the full period for a given seed.

Maybe this was already what you meant, but it isn’t totally clear from the phrasing, and I know there’s a lot of confusion out there about repeating output vs. repeating sequence vs. period vs. full period.

Cheers!

LikeLike

]]>LikeLike

]]>LikeLike

]]>LikeLike

]]>By default, some functions set the seed for you based on the system clock so you can call random(samples=10) twice, milliseconds apart, and two completely different sets of random numbers are sampled. Alternatively, if you and your friend each run the Mersenne twister on your own computers but both set the same seed (ie random(samples=10, seed=42) ), you will generate the same numbers. This determinism is completely opposite of what we consider random behavior, but keep in mind it’s not necessarily their predictability that’s important but moreso that the numbers the algorithm outputs follow a uniform distribution over the interval.

As if this blog couldn’t get nerdier, I’ll try to better explain using the example of a rubiks cube. If you and your friend start out with rubiks cubes oriented exactly the same with each square matching (ie you start with the same seeds), performing the same twists on your respective cubes (ie turn the right face clockwise, front face counterclockwise, and so on) will leave you with matching cubes. However if you and your friend each scramble your cubes differently without telling each other (ie using different seeds), then performing the same moves as before will leave you completely different looking cubes.

LikeLike

]]>LikeLike

]]>