in reply to Re^10: How likely is rand() to repeat?
in thread How likely is rand() to repeat?

By that assessment, then neither is MT19973 a "32-bit PRNG", so basing probabilities relating to its use upon 32-bits are wrong also
MT19973 generates 32 bit numbers. It will not generate more than 232 different numbers. It takes 32 bits as a seed. It uses just short of 20k bits to keep state. I don't know what the term "k-bit PRNG" exactly means, which why I tried avoiding that term and keep using seed and state sizes.
There are 232 seeds. Each of them starts a different sequence.
Are you sure about that?

Sure it isn't a single, 4e6001 value non-repeating sequence, and all the seeding does it start you at a different place within it.

Fine, whatever. Doesn't make a iota difference to the argument. But if you want to split hairs, be my guest. So you have 232 different starting points in the sequence.

Replies are listed 'Best First'.
Re^12: How likely is rand() to repeat?
by BrowserUk (Patriarch) on Mar 09, 2012 at 17:52 UTC
    MT19973 generates 32 bit numbers. It will not generate more than 232 different numbers. It takes 32 bits as a seed.

    If the important bit is that it produces 32-bit numbers and is seeded by a 32-bit number -- though from memory, the underlying C implementation can be seeded with 640 32-bit numbers, as can Math::Random::MT::Auto I believe; but let's skip that detail -- why do you think it is named MT19937?

    But if you want to split hairs, be my guest.

    You started it. I was responding to you.

    And it does make a difference.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      why do you think it is named MT19937?
      Lemme guess, because they followed the example of drand48, and put the number of number of bits that's needed for the state in the name? Or perhaps because it's related to the length of the period? Not quite sure which point you're trying to make. I never claimed it was a "32-bit PRNG", but I guess you seem to think it is. After all, a few posts ago, you write By that assessment, then neither is MT19973 a "32-bit PRNG", which makes me think that's a classification that's important to you.
      And it does make a difference.
      Well, that's fine. It doesn't make a difference to me, and if all you can say about the difference that it exists, I cannot imagine it's an important difference.

        Okay. When reason fails, how's about a little empirical evidence?

        #! perl -slw use strict; use Math::Random::MT qw[ rand srand ]; $|++; my @c = ( 'A'..'Z', 'a'..'z', 0..9 ); for my $run ( 1 .. 1e6 ) { my %seen; keys %seen = 1e6; printf "\rrun: $run"; for my $id ( 1 .. 1e6 ) { srand( $run + $id ); my $ID = join '', map $c[ int rand( 62 ) ], 1 .. 25; warn "Dup $ID at $run/$id" if exists $seen{ $ID }; undef $seen{ $ID }; } } __END__ C:\test>"IDrand(62)x25.pl" run: 254

        That console log is a snapshot. After generating 254 sets of 1 million 25-char keys, with each key being generated at a new seed position, NO DUPS SEEN!

        How long will it need to run before you are convinced that the OP is safe to use this?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?