Originally Posted by
Salem
But if you keep changing the seed too often, what you do end up doing is risking landing on some sub-sequence you've already used. This most definitely isn't random.
Lets say 1 5 9 3 2, then you call srand() again, and get 9 3 2 8
that's a great point. notice though, that you only risk running same "sub-sequnce" if you accept multiple outputs for each seed. however, if you're re-seeding randomly for 'each' output, there is no risk of ending up with a previously received sequence, since you effectively reset srand for each output.
so its not: srand() -> 1 5 9 3 2, "then you call srand() again" srand() -> 9 3 2........
but: srand() -> 1, srand() -> 8, srand() -> 2, srand() -> x,........
Originally Posted by
Salem
Any decent run-length from a good random number generator (which rand() isn't) is going to be just as good as any other sequence. Calling srand() multiple times at BEST does nothing useful, and has a number of potential pit-falls which are not easy to predict (or detect).
> here's what I got my re-seeding srand() everytime with the output of the MT19937 prng:
Why are you messing with rand() when you've got MT to play with?
the reason why I was using this rather unusual combination of MT and rand() was in the hope that the combination would somehow 'compound' the randomness.
in conclusion:
Code:
for(i=0;i<999,999;i++)
{ srand(MT.out);
finalout = rand();
}
is MAYBE, but probably not better than:
Code:
final_out = MT.out;
but is definately no LESS effective than:
Code:
srand(MT.out);
for(i=0;i<999,999;i++)
{
finalout = rand();
}
and all of the above are definately better than (as stated in example from above):
Code:
for(i=0;i<10;i++)
{
srand(MT.out);
for(j=0;j<99,999;j++)
final_out = rand();
}