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

◆ GenrandRes53()

Function GenrandRes53 ( )

Uniform random numbers (53 bit real random numbers on [0, 1)) (Mersenne Twister)

Purpose
Generates uniformly distributed pseudo random numbers by Mersenne Twister (MT19937).
Returns
Double
53 bit real pseudo random number on [0, 1).
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 ten real pseudo random numbers in [0, 1). In this example, InitByArray() with tha array of 3 integers is used for initialization. InitGenrand() with the integer seed may also be used for initialization.
Sub Ex_GenrandRes53()
Dim InitKey(2) As Long, KeyLength As Long, I As Long
KeyLength = 3
InitKey(0) = 101: InitKey(1) = 2101: InitKey(2) = 50101
Call InitByArray(InitKey(), KeyLength)
For I = 1 To 10
Debug.Print GenrandRes53()
Next
End Sub
Example Results
0.24458671671262
0.349909365984602
9.04350819875991E-02
0.478045087586123
7.80156266035709E-02
0.75363765185477
0.553109521876539
0.824325697710808
0.22205005707693
0.756798373840869