3 Random number generators

Index - - Contents - - Previous chapter - Next chapter - - Previous page - Next page

3.1 Test evaluation of combined Tausworthe generator

    3         2         1
   10987654321098765432109876543210  Assume a 32 bit word.
   01-----------------------------1  I1= Mask1 (Mask1 is our first seed)
   11----------------10-----------0  I1 << Q1, (Q1=13)
   10----------------01-----------1  (I1 << Q1) ^ I1
   00----------------01-----------1  b = ((I1 << Q1) ^ I1) & Mask1
   11-----------------10----------0  I1 << S1, (S1=12)
   00-----------------------------0  b >> P1mS1, (P1mS1= 31-12= 19)
   11-----------------10----------0  (I1 << S1) ^ (b >> P1mS1)
   01-----------------10----------0  I1= ((I1 << S1) ^ (b >> P1mS1)) & Mask1
                                       = 2147479552
    3         2         1
   10987654321098765432109876543210
   0001---------------------------1  I2= Mask2 (Mask2 is our second seed)
   0111-------------------------100  I2 << Q2, (Q2=2)
   0110-------------------------011  (I2 << Q2) ^ I2
   0000-------------------------011  b = ((I2 << Q2) ^ I2) & Mask2
   1111----------10---------------0  I2 << S2, (S2=17)
   0000---------------------------0  b >> P2mS2, (P2mS2= 29-17= 12)
   1111----------10---------------0  (I2 << S2) ^ (b >> P2mS2)
   0001----------10---------------0  I2= ((I2 << S2) ^ (b >> P2mS2)) & Mask2
                                       = 536739840
    3         2         1
   10987654321098765432109876543210
   01-----------------10----------0  I1
   01----------10-----------------0  I2 << P1mP2 (P1mP2 = 31-29 = 2)
   00----------01-----10----------0  I1 ^ (I2 << P1mP2) = 520192
                                     combtaus = 2.4223328E-4

Combtaus in Fortran

	function combtaus(i1,i2)
	integer*4 i1,i2,b

c Tausworthe random number generator implemented by A. Torn 28.1.1992,
c see ACM Trans. on Modelling and Computer Simulation,1:2, 99-112 (1991).
c The parameters i1 and i2 should before the first call be initialized 
c to positive integers, i1 less or equal to 2147483647 and i2 less or 
c equal to 536870911 and should thereafter not be altered during the run.
c The result is a uniform random number in (0,1).

	b = jiand(jieor(jishft(i1,13),i1),2147483647)
	i1= jiand(jieor(jishft(i1,12),jishft(b,-19)),2147483647)
	b = jiand(jieor(jishft(i2,2),i2),536870911)
	i2= jiand(jieor(jishft(i2,17),jishft(b,-12)),536870911)
	combtaus = jieor(i1,jishft(i2,2))*4.656612873d-10

	return
	end