C# 클래스 OpenTK.MersenneTwister

Generates pseudo-random numbers using the Mersenne Twister algorithm.
상속: System.Random
파일 보기 프로젝트 열기: smalld/particle_system

공개 메소드들

메소드 설명
MersenneTwister ( ) : System

Creates a new pseudo-random number generator with a default seed.

new System.Random().Random.Next() is used for the seed.

MersenneTwister ( Int32 seed ) : System

Creates a new pseudo-random number generator with a given seed.

Next ( ) : Int32

Returns the next pseudo-random Int32.

Next ( Int32 maxValue ) : Int32

Returns the next pseudo-random Int32 up to maxValue.

Next ( Int32 minValue, Int32 maxValue ) : Int32

Returns the next pseudo-random Int32 at least minValue and up to maxValue.

NextBytes ( Byte buffer ) : void

Fills a buffer with pseudo-random bytes.

NextDouble ( ) : Double

Returns the next pseudo-random Double value.

There are two common ways to create a double floating point using MT19937: using GenerateUInt32 and dividing by 0xFFFFFFFF + 1, or else generating two double words and shifting the first by 26 bits and adding the second.

In a newer measurement of the randomness of MT19937 published in the journal "Monte Carlo Methods and Applications, Vol. 12, No. 5-6, pp. 385 – 393 (2006)" entitled "A Repetition Test for Pseudo-Random Number Generators", it was found that the 32-bit version of generating a double fails at the 95% confidence level when measuring for expected repetitions of a particular number in a sequence of numbers generated by the algorithm.

Due to this, the 53-bit method is implemented here and the 32-bit method of generating a double is not. If, for some reason, the 32-bit method is needed, it can be generated by the following: (Double)NextUInt32() / ((UInt64)UInt32.MaxValue + 1);

NextDouble ( System.Boolean includeOne ) : Double

Returns a pseudo-random number greater than or equal to zero, and either strictly less than one, or less than or equal to one, depending on the value of the given parameter.

NextDoublePositive ( ) : Double

Returns a pseudo-random number greater than 0.0 and less than 1.0.

NextSingle ( ) : System.Single

Returns a pseudo-random number between 0.0 and 1.0.

NextSingle ( System.Boolean includeOne ) : System.Single

Returns a pseudo-random number greater than or equal to zero, and either strictly less than one, or less than or equal to one, depending on the value of the given boolean parameter.

NextSinglePositive ( ) : System.Single

Returns a pseudo-random number greater than 0.0 and less than 1.0.

NextUInt32 ( ) : UInt32

Returns the next pseudo-random UInt32.

NextUInt32 ( UInt32 maxValue ) : UInt32

Returns the next pseudo-random UInt32 up to maxValue.

NextUInt32 ( UInt32 minValue, UInt32 maxValue ) : UInt32

Returns the next pseudo-random UInt32 at least minValue and up to maxValue.

보호된 메소드들

메소드 설명
GenerateUInt32 ( ) : UInt32

Generates a new pseudo-random UInt32.

비공개 메소드들

메소드 설명
compute53BitRandom ( Double translate, Double scale ) : Double
init ( UInt32 seed ) : void
temperingShiftL ( UInt32 y ) : UInt32
temperingShiftS ( UInt32 y ) : UInt32
temperingShiftT ( UInt32 y ) : UInt32
temperingShiftU ( UInt32 y ) : UInt32

메소드 상세

GenerateUInt32() 보호된 메소드

Generates a new pseudo-random UInt32.
protected GenerateUInt32 ( ) : UInt32
리턴 System.UInt32

MersenneTwister() 공개 메소드

Creates a new pseudo-random number generator with a default seed.
new System.Random().Random.Next() is used for the seed.
public MersenneTwister ( ) : System
리턴 System

MersenneTwister() 공개 메소드

Creates a new pseudo-random number generator with a given seed.
public MersenneTwister ( Int32 seed ) : System
seed System.Int32 A value to use as a seed.
리턴 System

Next() 공개 메소드

Returns the next pseudo-random Int32.
public Next ( ) : Int32
리턴 System.Int32

Next() 공개 메소드

Returns the next pseudo-random Int32 up to maxValue.
/// When < 0. ///
public Next ( Int32 maxValue ) : Int32
maxValue System.Int32 The maximum value of the pseudo-random number to create.
리턴 System.Int32

Next() 공개 메소드

Returns the next pseudo-random Int32 at least minValue and up to maxValue.
/// If >= . ///
public Next ( Int32 minValue, Int32 maxValue ) : Int32
minValue System.Int32 The minimum value of the pseudo-random number to create.
maxValue System.Int32 The maximum value of the pseudo-random number to create.
리턴 System.Int32

NextBytes() 공개 메소드

Fills a buffer with pseudo-random bytes.
/// If == . ///
public NextBytes ( Byte buffer ) : void
buffer Byte The buffer to fill.
리턴 void

NextDouble() 공개 메소드

Returns the next pseudo-random Double value.

There are two common ways to create a double floating point using MT19937: using GenerateUInt32 and dividing by 0xFFFFFFFF + 1, or else generating two double words and shifting the first by 26 bits and adding the second.

In a newer measurement of the randomness of MT19937 published in the journal "Monte Carlo Methods and Applications, Vol. 12, No. 5-6, pp. 385 – 393 (2006)" entitled "A Repetition Test for Pseudo-Random Number Generators", it was found that the 32-bit version of generating a double fails at the 95% confidence level when measuring for expected repetitions of a particular number in a sequence of numbers generated by the algorithm.

Due to this, the 53-bit method is implemented here and the 32-bit method of generating a double is not. If, for some reason, the 32-bit method is needed, it can be generated by the following: (Double)NextUInt32() / ((UInt64)UInt32.MaxValue + 1);

public NextDouble ( ) : Double
리턴 Double

NextDouble() 공개 메소드

Returns a pseudo-random number greater than or equal to zero, and either strictly less than one, or less than or equal to one, depending on the value of the given parameter.
public NextDouble ( System.Boolean includeOne ) : Double
includeOne System.Boolean /// If , the pseudo-random number returned will be /// less than or equal to one; otherwise, the pseudo-random number returned will /// be strictly less than one. ///
리턴 Double

NextDoublePositive() 공개 메소드

Returns a pseudo-random number greater than 0.0 and less than 1.0.
public NextDoublePositive ( ) : Double
리턴 Double

NextSingle() 공개 메소드

Returns a pseudo-random number between 0.0 and 1.0.
public NextSingle ( ) : System.Single
리턴 System.Single

NextSingle() 공개 메소드

Returns a pseudo-random number greater than or equal to zero, and either strictly less than one, or less than or equal to one, depending on the value of the given boolean parameter.
public NextSingle ( System.Boolean includeOne ) : System.Single
includeOne System.Boolean /// If , the pseudo-random number returned will be /// less than or equal to one; otherwise, the pseudo-random number returned will /// be strictly less than one. ///
리턴 System.Single

NextSinglePositive() 공개 메소드

Returns a pseudo-random number greater than 0.0 and less than 1.0.
public NextSinglePositive ( ) : System.Single
리턴 System.Single

NextUInt32() 공개 메소드

Returns the next pseudo-random UInt32.
public NextUInt32 ( ) : UInt32
리턴 System.UInt32

NextUInt32() 공개 메소드

Returns the next pseudo-random UInt32 up to maxValue.
public NextUInt32 ( UInt32 maxValue ) : UInt32
maxValue System.UInt32 /// The maximum value of the pseudo-random number to create. ///
리턴 System.UInt32

NextUInt32() 공개 메소드

Returns the next pseudo-random UInt32 at least minValue and up to maxValue.
/// If >= . ///
public NextUInt32 ( UInt32 minValue, UInt32 maxValue ) : UInt32
minValue System.UInt32 The minimum value of the pseudo-random number to create.
maxValue System.UInt32 The maximum value of the pseudo-random number to create.
리턴 System.UInt32