dhardy / rand

http://doc.rust-lang.org/rand
Other
2 stars 2 forks source link

Restrict the seed type to a few more array sizes #80

Closed pitdicker closed 6 years ago

pitdicker commented 6 years ago

I am not sure this is a good idea, but this are seed sizes I encountered with the RNG's implemented in small-rngs.

dhardy commented 6 years ago

Down to 32-bit? You said yourself you thought 128-bits should be a minimum, didn't you?

My view is that we should provide a "good seeding" function, not the default one, if it's possible to seed a small PRNG from a larger seed. We could also provide a function like X::seed_official(n: u32) if applicable.

I guess though we can accommodate all those sizes if need be.

pitdicker commented 6 years ago

I did :smile:, as a minimum for 'worry free initialisation'. I would not recommend seeding with something less than 96 bits.

I definitely agree that if we can provide a better seeding function, we should do so.

But I have two cases in mind where seeding with 32 bits is best: Jenkins small fast RNG because only for those seeds is experimentally proven that there are no very short cycles. And I have seen a 32-bit Xorshift used in data structures as a super tiny source of just a little randomness.

It is of course possible to seed with a larger array, and only use a part of it. But this seems more 'honest' to me.

I didn't like adding the extra sizes, but can't really see harm in it either.

pitdicker commented 6 years ago

Shall I put some 'not recommended' comments after the small sizes?