I would like to implement a 64-bit L'Ecuyer LCG
on MATLAB, since I wrote it on C, to replicate some results.
The pure Mutiplicative LCG (MLCG) is easily obtained by X_{n+1} = a * X_{n} mod m
, where a
and m
are the two constant taken from the table of L'Ecuyer's article. In my case I used
a = 1181783497276652981
m = 0xFFFFFFFFFFFFFFFF = 2^64 - 1
As pointed out e.g. here in C there are no problem in doing multiplication of 64-bits a
and X_{n}
is automagically truncated to the remainder of division by 2^64 - 1
, so that I only need to do
rnd = A_ecu1b64 * rnd;
to obtain the successive random number. In MATLAB, sadly, this is not like so, instead when a * X_{n}
is bigger than m
is gets truncated to 2^64-1
and then the successive remainders are always 0.
How can I implement the same MLCG on MATLAB?
Aucun commentaire:
Enregistrer un commentaire