public class TRandomGenerator
Random generator.
Use this class to generate streams of random numbers. To achieve independence between two series of random numbers there are three options: 1. create several instances of this class and initialize each with a different seed. (and maybe a different random generator). 2. create a single instance of this class and use leapfroging. 3. create a single instance of this class and use block splitting.
Examples
csharp
TRandomGenerator rnd;
TVecInt IntVec;
if Seed = -1 then Seed = aRound(Random*High(Cardinal));
rnd = TRandomGenerator.Create;
IntVec = TVecInt.Create;
try
{
IntVec.Size(Results.Length, prInt32);
rnd.StreamCount = 1;
rnd.Init(rgMRG32k3a,Seed);
rnd.Streamsnew double[] {0}.RandomBinomial(IntVec,an,p);
Results.Copy(IntVec);
}
finally
{
rnd.Free;
IntVec.Free;
end
}
Properties
| Name | Type | Description |
|---|---|---|
| BasicRngType | TBasicRandomGenerator | The basic random generator used. |
| BlockStep | Int32 | A parameter to the block splitting method to achieve stream independence. |
| Item | TRngStream | A list of independent random streams. |
| Seed | Int32 | The random generator seed. |
| StreamCount | Int32 | Number of independent random streams. |
| StreamIndependence | TRngStreamIndependence | Specifies the method to achieve random stream independence. |
Methods
| Name | Description |
|---|---|
| Init | Initializes random generator. |
| LoadFromFile | Loads random generator state from File. |
| LoadFromStream | Loads random generator state from Src. |
| SaveToFile | Saves random generator state to File. |
| SaveToStream | Saves random generator state to Dst. |