lcg

why 48 bit seed in util Random class?

Why this class uses 48 bit seed in its linear congruence formula? I would have expected 32 or 64... I know it takes higher order bits when asked for 32 bit values. But why only 16 more additional bits? Was it a "random" choice? ...

Is Lightweight Code Generation (LCG) dead?

In the .NET 2.0-3.5 frameworks, LCG (aka the DynamicMethod class) was a decent way to emit lightweight methods at runtime when no class structure was needed to support them. In .NET 4.0, expression trees now support statements and blocks, and as such appear to provide sufficient functionality to build just about any functionality you co...

How to generate a predictable shuffling of a sequence without generating the whole sequence in advance?

The following python code describes exactly what I want to achieve for a sequence of arbitrary size (population): import random fixed_seed = 1 #generate the same sequence every time with a fixed seed population = 1000 sample_count = 5 #demonstration number num_retries = 3 #just enough to show the repeatable behaviour for trynum in xran...