Crystal AI  1.0.0
Crystal.Pcg Class Reference

PCG (Permuted Congruential Generator) is a C# port from C the base PCG generator presented in "PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation" by Melissa E. O'Neill. The code follows closely the one made available by O'Neill at her site: http://www.pcg-random.org/download.html To understand how exactly this generator works read this: http://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf More...

Public Member Functions

virtual int Next ()
 Random integer in the interval [0, int.MaxValue]. More...
 
virtual int Next (int maxExclusive)
 Random integer in the semi-open interval [0, maxExclusive ). More...
 
virtual int Next (int minInclusive, int maxExclusive)
 Random integer in the interval [minInclusive , maxExclusive ). More...
 
int[] NextInts (int count)
 Array of size count of random integers in the interval [0, int.MaxValue]. More...
 
int[] NextInts (int count, int maxExclusive)
 Array of size count of random integers in the interval [0, maxExclusive ). More...
 
int[] NextInts (int count, int minInclusive, int maxExclusive)
 Array of size count of random integers in the interval [minInclusive , maxExclusive ). More...
 
uint NextUInt ()
 Random unsigned integer in the interval [0, uint.MaxValue]. More...
 
uint NextUInt (uint maxExclusive)
 Random unsigned integer in the interval [0, maxExclusive ). More...
 
uint NextUInt (uint minInclusive, uint maxExclusive)
 Random unsigned integer in the interval [minInclusive , maxExclusive ). More...
 
uint[] NextUInts (int count)
 Array of size count of unsigned integers in the interval [0, uint.MaxValue]. More...
 
uint[] NextUInts (int count, uint maxExclusive)
 Array of size count of unsigned integers in the interval [0, maxExclusive ). More...
 
uint[] NextUInts (int count, uint minInclusive, uint maxExclusive)
 Array of size count of unsigned integers in the interval [minInclusive , maxExclusive ). More...
 
virtual float NextFloat ()
 Random single precision floating point number in the interval [0,1]. More...
 
virtual float NextFloat (float maxInclusive)
 Random single precision floating point number in the interval [0, maxInclusive ]. More...
 
virtual float NextFloat (float minInclusive, float maxInclusive)
 Random single precision floating point number in the interval [minInclusive , maxInclusive ]. More...
 
float[] NextFloats (int count)
 Array of size count of single precision floating point random numbers in the interval [0,1]. More...
 
float[] NextFloats (int count, float maxInclusive)
 Array of size count of single precision floating point random numbers in the interval [0, maxInclusive ]. More...
 
float[] NextFloats (int count, float minInclusive, float maxInclusive)
 Array of size count of single precision floating point random numbers in the interval [minInclusive , maxInclusive ]. More...
 
virtual double NextDouble ()
 Random double precision floating point number in the interval [0, 1]. More...
 
virtual double NextDouble (double maxInclusive)
 Random double precision floating point number in the interval [0, maxInclusive ]. More...
 
virtual double NextDouble (double minInclusive, double maxInclusive)
 Random double precision floating point number in the interval [minInclusive , maxInclusive ]. More...
 
double[] NextDoubles (int count)
 Array of size count of double precision floating point random numbers in the interval [0, 1]. More...
 
double[] NextDoubles (int count, double maxInclusive)
 Array of size count of double precision floating point random numbers in the interval [0, maxInclusive . More...
 
double[] NextDoubles (int count, double minInclusive, double maxInclusive)
 Array of size count of double precision floating point random numbers in the interval [minInclusive , maxInclusive ]. More...
 
byte NextByte ()
 Random byte. More...
 
byte[] NextBytes (int count)
 Array of size count of random bytes. More...
 
bool NextBool ()
 Random boolean. More...
 
bool[] NextBools (int count)
 Array of size count of random booleans. More...
 
int PeriodPow2 ()
 Base 2 exponent of the period of this generator, i.e. Period of Generator = 2^PeriodPow2(). More...
 
void SetStream (int sequence)
 Set the stream for this generator. More...
 
void SetStream (ulong sequence)
 Set the stream for this generator. More...
 
ulong CurrentStream ()
 Query the current stream used by this generator. More...
 
 Pcg ()
 Initializes a new instance of the T:Crystal.Pcg class. More...
 
 Pcg (int seed)
 Initializes a new instance of the T:Crystal.Pcg class. More...
 
 Pcg (int seed, int sequence)
 Initializes a new instance of the T:Crystal.Pcg class. More...
 
 Pcg (ulong seed, ulong sequence=ShiftedIncrement)
 Initializes a new instance of the T:Crystal.Pcg class. More...
 

Static Public Attributes

static Pcg Default => _defaultInstance ?? (_defaultInstance = new Pcg(PcgSeed.GuidBasedSeed()))
 Default instance. More...
 

Detailed Description

PCG (Permuted Congruential Generator) is a C# port from C the base PCG generator presented in "PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation" by Melissa E. O'Neill. The code follows closely the one made available by O'Neill at her site: http://www.pcg-random.org/download.html To understand how exactly this generator works read this: http://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf

Constructor & Destructor Documentation

Crystal.Pcg.Pcg ( )
inline

Initializes a new instance of the T:Crystal.Pcg class.

Crystal.Pcg.Pcg ( int  seed)
inline

Initializes a new instance of the T:Crystal.Pcg class.

Parameters
seedThe seed.
Crystal.Pcg.Pcg ( int  seed,
int  sequence 
)
inline

Initializes a new instance of the T:Crystal.Pcg class.

Parameters
seedThe seed.
sequenceThe sequence.
Crystal.Pcg.Pcg ( ulong  seed,
ulong  sequence = ShiftedIncrement 
)
inline

Initializes a new instance of the T:Crystal.Pcg class.

Parameters
seedThe seed.
sequenceThe sequence.

Member Function Documentation

ulong Crystal.Pcg.CurrentStream ( )
inline

Query the current stream used by this generator.

virtual int Crystal.Pcg.Next ( )
inlinevirtual

Random integer in the interval [0, int.MaxValue].

virtual int Crystal.Pcg.Next ( int  maxExclusive)
inlinevirtual

Random integer in the semi-open interval [0, maxExclusive ).

Parameters
maxExclusiveThe maximum value; exclusive.
Exceptions
T:System.ArgumentExceptionMax Exclusive must be positive
virtual int Crystal.Pcg.Next ( int  minInclusive,
int  maxExclusive 
)
inlinevirtual

Random integer in the interval [minInclusive , maxExclusive ).

Parameters
minInclusiveThe minimum value; inclusive.
maxExclusiveThe maximum value; exclusive.
Exceptions
T:System.ArgumentExceptionMaxExclusive must be larger than MinInclusive
bool Crystal.Pcg.NextBool ( )
inline

Random boolean.

bool [] Crystal.Pcg.NextBools ( int  count)
inline

Array of size count of random booleans.

Parameters
countThe count.
Exceptions
T:System.ArgumentExceptionZero count
byte Crystal.Pcg.NextByte ( )
inline

Random byte.

byte [] Crystal.Pcg.NextBytes ( int  count)
inline

Array of size count of random bytes.

Parameters
countThe count.
Exceptions
T:System.ArgumentExceptionZero count
virtual double Crystal.Pcg.NextDouble ( )
inlinevirtual

Random double precision floating point number in the interval [0, 1].

virtual double Crystal.Pcg.NextDouble ( double  maxInclusive)
inlinevirtual

Random double precision floating point number in the interval [0, maxInclusive ].

Parameters
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionMax must be larger than 0
virtual double Crystal.Pcg.NextDouble ( double  minInclusive,
double  maxInclusive 
)
inlinevirtual

Random double precision floating point number in the interval [minInclusive , maxInclusive ].

Parameters
minInclusiveThe minimum inclusive.
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionMax must be larger than min
double [] Crystal.Pcg.NextDoubles ( int  count)
inline

Array of size count of double precision floating point random numbers in the interval [0, 1].

Parameters
countThe count.
Exceptions
T:System.ArgumentExceptionZero count
double [] Crystal.Pcg.NextDoubles ( int  count,
double  maxInclusive 
)
inline

Array of size count of double precision floating point random numbers in the interval [0, maxInclusive .

Parameters
countThe count.
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionZero count
double [] Crystal.Pcg.NextDoubles ( int  count,
double  minInclusive,
double  maxInclusive 
)
inline

Array of size count of double precision floating point random numbers in the interval [minInclusive , maxInclusive ].

Parameters
countThe count.
minInclusiveThe minimum inclusive.
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionZero count
virtual float Crystal.Pcg.NextFloat ( )
inlinevirtual

Random single precision floating point number in the interval [0,1].

virtual float Crystal.Pcg.NextFloat ( float  maxInclusive)
inlinevirtual

Random single precision floating point number in the interval [0, maxInclusive ].

Parameters
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionMaxInclusive must be larger than 0
virtual float Crystal.Pcg.NextFloat ( float  minInclusive,
float  maxInclusive 
)
inlinevirtual

Random single precision floating point number in the interval [minInclusive , maxInclusive ].

Parameters
minInclusiveThe minimum inclusive.
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionMax must be larger than min
float [] Crystal.Pcg.NextFloats ( int  count)
inline

Array of size count of single precision floating point random numbers in the interval [0,1].

Parameters
countThe count.
Exceptions
T:System.ArgumentExceptionZero count
float [] Crystal.Pcg.NextFloats ( int  count,
float  maxInclusive 
)
inline

Array of size count of single precision floating point random numbers in the interval [0, maxInclusive ].

Parameters
countThe count.
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionZero count
float [] Crystal.Pcg.NextFloats ( int  count,
float  minInclusive,
float  maxInclusive 
)
inline

Array of size count of single precision floating point random numbers in the interval [minInclusive , maxInclusive ].

Parameters
countThe count.
minInclusiveThe minimum inclusive.
maxInclusiveThe maximum inclusive.
Exceptions
T:System.ArgumentExceptionZero count
int [] Crystal.Pcg.NextInts ( int  count)
inline

Array of size count of random integers in the interval [0, int.MaxValue].

Parameters
countThe count.
Exceptions
T:System.ArgumentExceptionZero count
int [] Crystal.Pcg.NextInts ( int  count,
int  maxExclusive 
)
inline

Array of size count of random integers in the interval [0, maxExclusive ).

Parameters
countThe count.
maxExclusiveThe maximum value; exclusive.
Exceptions
T:System.ArgumentExceptionZero count
int [] Crystal.Pcg.NextInts ( int  count,
int  minInclusive,
int  maxExclusive 
)
inline

Array of size count of random integers in the interval [minInclusive , maxExclusive ).

Parameters
countThe count.
minInclusiveThe minimum value; inclusive.
maxExclusiveThe maximum value; exclusive.
Exceptions
T:System.ArgumentExceptionZero count
uint Crystal.Pcg.NextUInt ( )
inline

Random unsigned integer in the interval [0, uint.MaxValue].

uint Crystal.Pcg.NextUInt ( uint  maxExclusive)
inline

Random unsigned integer in the interval [0, maxExclusive ).

Parameters
maxExclusiveThe maximum value; exclusive.
uint Crystal.Pcg.NextUInt ( uint  minInclusive,
uint  maxExclusive 
)
inline

Random unsigned integer in the interval [minInclusive , maxExclusive ).

Parameters
minInclusiveThe minimum value; inclusive.
maxExclusiveThe maximum value; exclusive.
Exceptions
T:System.ArgumentException
uint [] Crystal.Pcg.NextUInts ( int  count)
inline

Array of size count of unsigned integers in the interval [0, uint.MaxValue].

Parameters
countThe count.
Exceptions
T:System.ArgumentExceptionZero count
uint [] Crystal.Pcg.NextUInts ( int  count,
uint  maxExclusive 
)
inline

Array of size count of unsigned integers in the interval [0, maxExclusive ).

Parameters
countThe count.
maxExclusiveThe maximum exclusive.
Exceptions
T:System.ArgumentExceptionZero count
uint [] Crystal.Pcg.NextUInts ( int  count,
uint  minInclusive,
uint  maxExclusive 
)
inline

Array of size count of unsigned integers in the interval [minInclusive , maxExclusive ).

Parameters
countThe count.
minInclusiveThe minimum inclusive.
maxExclusiveThe maximum exclusive.
Exceptions
T:System.ArgumentExceptionZero count
int Crystal.Pcg.PeriodPow2 ( )
inline

Base 2 exponent of the period of this generator, i.e. Period of Generator = 2^PeriodPow2().

void Crystal.Pcg.SetStream ( int  sequence)
inline

Set the stream for this generator.

Parameters
sequenceThe sequence.
void Crystal.Pcg.SetStream ( ulong  sequence)
inline

Set the stream for this generator.

Parameters
sequenceThe sequence.

Member Data Documentation

Pcg Crystal.Pcg.Default => _defaultInstance ?? (_defaultInstance = new Pcg(PcgSeed.GuidBasedSeed()))
static

Default instance.


The documentation for this class was generated from the following file: