Class ALFGenerator
Represents a Additive Lagged Fibonacci pseudo-random number generator.
Inherited Members
Namespace: Experior.Core.Mathematics.Statistics.Generators.Pseudo
Assembly: Experior.Core.dll
Syntax
public class ALFGenerator : Generator
Remarks
The ALFGenerator type bases upon the implementation in the Boost Random Number Library. It uses the modulus 232 and by default the "lags" 418 and 1279, which can be adjusted through the associated ShortLag and LongLag properties. Some popular pairs are presented on Wikipedia - Lagged Fibonacci generator.
Constructors
ALFGenerator()
Initializes a new instance of the ALFGenerator class, using a time-dependent default seed value.
Declaration
public ALFGenerator()
ALFGenerator(Int32)
Initializes a new instance of the ALFGenerator class, using the specified seed value.
Declaration
public ALFGenerator(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. |
ALFGenerator(UInt32)
Initializes a new instance of the StandardGenerator class, using the specified seed value.
Declaration
[CLSCompliant(false)]
public ALFGenerator(uint seed)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | seed | An unsigned number used to calculate a starting value for the pseudo-random number sequence. |
Properties
CanReset
Gets a value indicating whether the ALFGenerator 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
LongLag
Gets or sets the long lag of the Lagged Fibonacci pseudo-random number generator.
Declaration
public int LongLag { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The long lag. |
Remarks
Call IsValidLongLag(Int32) to determine whether a value is valid and therefor assignable.
ShortLag
Gets or sets the short lag of the Lagged Fibonacci pseudo-random number generator.
Declaration
public int ShortLag { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The short lag. |
Remarks
Call IsValidShortLag(Int32) to determine whether a value is valid and therefor assignable.
Methods
IsValidLongLag(Int32)
Determines whether the specified value is valid for parameter LongLag.
Declaration
public bool IsValidLongLag(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if value is greater than ShortLag; otherwise, false. |
IsValidShortLag(Int32)
Determines whether the specified value is valid for parameter ShortLag.
Declaration
public bool IsValidShortLag(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if value is greater than 0; otherwise, false. |
Next()
Returns a nonnegative random number less than System.Int32.MaxValue.
Declaration
public override int Next()
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to 0, and less than System.Int32.MaxValue; that is,
the range of return values includes 0 but not |
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
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
Next(Int32, Int32)
Returns a random number within the 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
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
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.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
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 0.0, 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 |
NextInclusiveMaxValue()
Returns a nonnegative random number less than or equal to System.Int32.MaxValue.
Declaration
public int NextInclusiveMaxValue()
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to 0, and less than or equal to System.Int32.MaxValue;
that is, the range of return values includes 0 and |
NextUInt()
Returns an unsigned random number.
Declaration
[CLSCompliant(false)]
public uint NextUInt()
Returns
Type | Description |
---|---|
System.UInt32 | A 32-bit unsigned integer greater than or equal to System.UInt32.MinValue and
less than or equal to |
Reset()
Resets the ALFGenerator, so that it produces the same pseudo-random number sequence again.
Declaration
public override bool Reset()
Returns
Type | Description |
---|---|
System.Boolean | true. |