Class StandardGenerator
Represents a simple pseudo-random number generator.
Inherited Members
Namespace: Experior.Core.Mathematics.Statistics.Generators.Pseudo
Assembly: Experior.Core.dll
Syntax
public class StandardGenerator : Generator
Remarks
The StandardGenerator type internally uses an instance of the System.Random type to generat pseudo-random numbers.
Constructors
StandardGenerator()
Initializes a new instance of the StandardGenerator class, using a time-dependent default seed value.
Declaration
public StandardGenerator()
StandardGenerator(Int32)
Initializes a new instance of the StandardGenerator class, using the specified seed value.
Declaration
public StandardGenerator(int seed)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | seed | A number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used. |
Properties
CanReset
Gets a value indicating whether the StandardGenerator can be reset, so that it produces the same pseudo-random number sequence again.
Declaration
public override bool CanReset { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Overrides
Seed
Change the seed of the random generator and reset it.
Declaration
public int Seed { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The seed. |
Methods
Next()
Returns a nonnegative random number.
Declaration
public override int Next()
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to zero and less than System.Int32.MaxValue. |
Overrides
Next(Int32)
Returns a nonnegative random number less than the specified maximum.
Declaration
public override int Next(int maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxValue | The exclusive upper bound of the random number to be generated.
|
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to 0, and less than |
Overrides
Next(Int32, Int32)
Returns a random number within a specified range.
Declaration
public override int Next(int minValue, int maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minValue | The inclusive lower bound of the random number to be generated. |
System.Int32 | maxValue | The exclusive upper bound of the random number to be generated.
|
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to |
Overrides
NextBoolean()
Returns a random Boolean value.
Declaration
public override bool NextBoolean()
Returns
Type | Description |
---|---|
System.Boolean | A System.Boolean value. |
Overrides
Remarks
Buffers 31 random bits for future calls, so the random number generator is only invoked once in every 31 calls.
NextBytes(Byte[])
Fills the elements of a specified array of bytes with random numbers.
Declaration
public override void NextBytes(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | An array of bytes to contain random numbers. |
Overrides
Remarks
Each element of the array of bytes is set to a random number greater than or equal to 0, and less than or equal to System.Byte.MaxValue.
NextDouble()
Returns a nonnegative floating point random number less than 1.0.
Declaration
public override double NextDouble()
Returns
Type | Description |
---|---|
System.Double | A double-precision floating point number greater than or equal to 0.0, and less than 1.0; that is, the range of return values includes 0.0 but not 1.0. |
Overrides
NextDouble(Double)
Returns a nonnegative floating point random number less than the specified maximum.
Declaration
public override double NextDouble(double maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Double | maxValue | The exclusive upper bound of the random number to be generated.
|
Returns
Type | Description |
---|---|
System.Double | A double-precision floating point number greater than or equal to zero, and less than |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
NextDouble(Double, Double)
Returns a floating point random number within the specified range.
Declaration
public override double NextDouble(double minValue, double maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Double | minValue | The inclusive lower bound of the random number to be generated.
The range between |
System.Double | maxValue | The exclusive upper bound of the random number to be generated.
|
Returns
Type | Description |
---|---|
System.Double | A double-precision floating point number greater than or equal to |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | |
System.ArgumentException |
Reset()
Resets the StandardGenerator, so that it produces the same pseudo-random number sequence again.
Declaration
public override bool Reset()
Returns
Type | Description |
---|---|
System.Boolean | true. |