Redzen.Numerics.XorShiftRandom.Reinitialise C# (CSharp) Method

Reinitialise() public method

Reinitialises using an int value as a seed.
public Reinitialise ( int seed ) : void
seed int
return void
        public void Reinitialise(int seed)
        {
            // The only stipulation stated for the xorshift RNG is that at least one of
            // the seeds x,y,z,w is non-zero. We fulfill that requirement by only allowing
            // resetting of the x seed.

            // The first random sample will be very closely related to the value of _x we set here.
            // Thus setting _x = seed will result in a close correlation between the bit patterns of the seed and
            // the first random sample, therefore if the seed has a pattern (e.g. 1,2,3) then there will also be
            // a recognisable pattern across the first random samples.
            //
            // Such a strong correlation between the seed and the first random sample is an undesirable
            // charactersitic of a RNG, therefore we significantly weaken any correlation by hashing the seed's bits.
            // This is achieved by multiplying the seed with four large primes each with bits distributed over the
            // full length of a 32bit value, finally adding the results to give _x.
            _x = (uint)(seed * 3575866506U);

            _y = Y;
            _z = Z;
            _w = W;

            _bitBuffer = 0;
            _bitMask=1;
        }