lundi 5 novembre 2018

Linear Congruence Algorithm in Excel

I'm trying to use the Linear Congruence Algorithm in Excel. I would like to generate a sequence M of 100 real numbers in the interval [-4, 4[.

I have been able to generate a sequence L of 100 integers in the range 0..255, but when I am try to generate real numbers in the interval [-4, 4[, the numbers are in the range of -3.9 to 4.

Excel Sheet View

M=1000000, and x0=34781 and a = 3821.

Initial:

=MOD($B$3*$B$5+1,255)

First Value (Between 0 and 255)

=MOD($B$3*E3+1,255)

However, this does generate a random number between the interval [-4, 4[:

=(E4/$B$4)*8-4

Thank you.




Aucun commentaire:

Enregistrer un commentaire