XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ RanfArray()

Sub RanfArray ( AA() As  Double,
N As  Long 
)

53 bit real random numbers in [0,1) (Lagged Fibonacci method)

Purpose
Generates 53 bit real random numbers in [0,1) by Lagged Fibonacci method.
Parameters
[out]AA()Array AA(LAA - 1) (LAA >= N)
Array of generated 53 bit real random numbers in [0,1)
[in]NNumber of random numbers to be generated. (N >= 100)
If N < 100, random numbers are not generated,
Note
N must be at least 100. It is recommended to generate, say, 1009 numbers but use only the first 100 of these. Usually use RanfArrNext so that these will be automatically done.
Reference
D. E. Knuth, “The Art of Computer Programming Third Edition, Vol.2 / Seminumerical Algorithms”, Addison Wesley Longman (1998)
Example Program
Generates ten 53 bit real random numbers. 1009 numbers are generated and the first ten of these are used.
Sub Ex_RanfArray()
Const N = 1009, Seed = 314159
Dim AA(N - 1) As Double, I As Long
Call RanfStart(Seed)
Call RanfArray(AA(), N)
For I = 0 To 9
Debug.Print AA(I)
Next
End Sub
Sub RanfStart(Seed As Long)
Initialization for real random number generator (Lagged Fibonacci method)
Sub RanfArray(AA() As Double, N As Long)
53 bit real random numbers in [0,1) (Lagged Fibonacci method)
Example Results
0.524684800201494
0.726548552471813
0.9609049752137
0.889272805173326
0.227826029210785
0.174781467409852
0.721634836341662
0.305582896514576
0.23246372865035
0.265391103319004