XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ GenrandInt32()

Function GenrandInt32 ( )

Uniform random numbers (unsigned 32 bit integer random numbers) (Mersenne Twister)

Purpose
Generates uniformly distributed pseudo random numbers by Mersenne Twister (MT19937).
Returns
Long
Unsigned 32 bit integer pseudo random number (In VBA, it is handled as the signed 32 bit integer (Long type)).
Note
This routine must be initialized by InitGenrand() or InitByArray() before generating random numbers. If this routine is called without an initialization, it will be automatically initialized by the default seed 5489.
Reference
Mersenne Twister Home Page
Example Program
Generate 10 unsigned 32 bit integer pseudo random numbers using 13 as the seed value for initialization.
Sub Ex_GenrandInt32()
Dim Seed As Long, I As Long
Seed = 13
Call InitGenrand(Seed)
For I = 1 To 10
Debug.Print GenrandInt32()
Next
End Sub
Sub InitGenrand(S As Long)
Initialization of random number generator (Mersenne Twister)
Example Results
-954760878
-1686456144
1020231754
-603726320
-754717978
-459635870
-147106060
769458329
-117677332
-1036873798