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

NextUInt() public method

Generates a uint. Values returned are over the full range of a uint, uint.MinValue to uint.MaxValue, inclusive. This is the fastest method for generating a single random number because the underlying random number generator algorithm generates 32 random bits that can be cast directly to a uint.
public NextUInt ( ) : uint
return uint
        public uint NextUInt()
        {
            uint t = _x^(_x<<11);
            _x=_y; _y=_z; _z=_w;
            return _w=(_w^(_w>>19))^(t^(t>>8));
        }

Usage Example

Example #1
0
        public void NextUInt()
        {
            int sampleCount = 10000000;
            XorShiftRandom rng = new XorShiftRandom();
            double[] sampleArr = new double[sampleCount];

            for(int i=0; i<sampleCount; i++){
                sampleArr[i] = rng.NextUInt();
            }

            UniformDistributionTest(sampleArr, 0.0, uint.MaxValue);
        }