C++ Logo

std-proposals

Advanced search

Re: Comments for P0205 and P2060: Mersenne twister can actually generate 7 and 13

From: Dimitrij Mijoski <dmjpp_at_[hidden]>
Date: Wed, 24 Nov 2021 17:05:03 +0100
On Tue, 2021-11-23 at 23:28 -0500, Jason McKesson via Std-Proposals
wrote:
> The SSeq constructor for MT is explicitly defined to generate a
> specific number of integers, sufficient to fill up the state. It
> generates no less and no more than that, no matter what their values
> are. The generated values are copied directly into the internal state.
>
> The MT constructor is defined to do some fiddling with the state in
> certain isolated circumstances, but it never *generates* more data.
> Nor is the SSeq required to provide any particular mechanism for
> generating bits. So whatever "this protection" is, it has nothing to
> do with the *mechanism* used to generate those bits.
>
> So yes, *any RNG engine* can be used to do the stretching, if it
> provides the SSeq interface. The SSeq interface is not *required* to
> be implemented by `seed_seq`.

I am well aware of this. But I'm under the impression that some people
want to completely sidestep the MT13997 constructor and write directly
into the state. That is 20 year old mistake, fixed in 2002, but I have
the feeling that fix got forgotten. Just look at this reddit comment,
it's terrible
https://www.reddit.com/r/cpp/comments/r0idct/underseeding_mt19937_introducing_xoshiro256ss/hlttb2t/?utm_source=reddit&utm_medium=web2x&context=3

The additional fiddling of the bits the MT constructor does is done in
all circumstances, not only in some. See overload 3
https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine/mersenne_twister_engine

Received on 2021-11-24 10:05:13