View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
TIMERESRCH TIMERESRCH is offline
external usenet poster
 
Posts: 2
Default Speed--Excel 2003 RAND vs. VBA Rnd...

I thought it might be a good idea to reproduce the section I referred to from
Microsoft's Knowledge Base article (828795):

The basic idea is to generate three streams of random numbers (in columns
headed "ix", "iy", and "iz") by a common technique and then to use the result
that if you take three random numbers on [0,1] and sum them, the fractional
part of the sum is itself a random number on [0,1]. The critical statements in
the Fortran code listing from the original Wichman and Hill article a

C IX, IY, IZ SHOULD BE SET TO INTEGER VALUES BETWEEN 1 AND 30000 BEFORE
FIRST ENTRY

IX = MOD(171 * IX, 30269)

IY = MOD(172 * IY, 30307)

IZ = MOD(170 * IZ, 30323)

RANDOM = AMOD(FLOAT(IX) / 30269.0 + FLOAT(IY) / 30307.0 + FLOAT(IZ) / 30323.0,
1.0)


Therefore IX, IY, IZ generate integers between 0 and 30268, 0 and 30306, and 0
and 30322 respectively. These are combined in the last statement to implement
the simple principle that was expressed earlier: if you take three random
numbers on [0,1] and sum them, the fractional part of the sum is itself a
random number on [0,1].


Paul Williams