Главная страница


ru.algorithms

 
 - RU.ALGORITHMS ----------------------------------------------------------------
 From : Max Alekseyev                        2:5015/60      08 Oct 2002  15:12:18
 To : Dmitry Grusdev
 Subject : ГЕHЕРАТОР СЛУЧАЙHЫХ ЧИСЕЛ
 -------------------------------------------------------------------------------- 
 
 
 Replying to a message of Dmitry Grusdev to All:
 
  DG> Hарод, может у кого есть генератор случайных чисел с большим периодом?
 
 Mersenne Twister имеет период 2^19937-1
 http://www.math.keio.ac.jp/~matumoto/emt.html
 
 А вот еще один от George Marsaglia с периодом более 10^9824:
 
 ===cut===
 /*
 George Marsaglia writes:
 "Try this, one of my latest RNG's:
  -------------------------------------------------------
 */
 
 static unsigned long Q[1019];
 unsigned long MWC1019(void)
 {unsigned long long t;
  static unsigned long c = 362436, i = 1018;
  t = 147669672LL*Q[i] + c; c = (t>>32);
 
  if(i>0) return(Q[i--] = t);
 
  i = 1018;  return(Q[0] = t);
 }
 
 unsigned long MWC1019(unsigned long m)
 {
     return MWC1019() % m;
 }
 
 /*
  -------------------------------------------------------
 It will provide random 32-bit integers at the rate of 300 million per
 second (on a 850MHz PC).
 
 It requires that you seed Q[0],Q[1],...Q[1018] with 32-bit random 
 integers, before calling MWC1019( ) in your main.  You might use a 
 good RNG such as KISS to fill the Q array.
 
 The period of MWC1019 exceeds 10^9824, making it billions and
 billions ... and billions times as long as the highly touted 
 longest-period RNG, the Mersenne twister.  It is also several times
 as fast and takes a few lines rather than several pages of code.  
 (This is not to say that the Mersenne twister is not a good RNG; it 
 is.  I just do not equate complexity of code with randomness.  It is 
 the complexity of the underlying randomness that counts.)
 
 As for randomness, it passes all tests in The Diehard Battery of
 Tests of Randomness
      http://stat.fsu.edu/pub/diehard as well as three new tough tests I have
 developed with the apparent 
 property that a RNG that passes tuftsts.c will pass all the tests in 
 Diehard.
 
 MWC1019 has the property that every possible sequence of 1018 
 successive 32-bit integers will appear somewhere in the full period,  
 for those concerned with the "equi-distribution" in dimensions 
 2,3,...1016,1017,1018.
 
 I welcome comments on timings or otherwise.
 
 George Marsaglia"
 */
 ===cut===
 
 Regards,      ш.ш
         Max    ~
 
 --- FleetStreet 1.27.3.8
  * Origin:  (2:5015/60)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 ГЕHЕРАТОР СЛУЧАЙHЫХ ЧИСЕЛ   Dmitry Grusdev   08 Oct 2002 16:43:58 
 ГЕHЕРАТОР СЛУЧАЙHЫХ ЧИСЕЛ   Max Alekseyev   08 Oct 2002 15:12:18 
 ГЕHЕРАТОР СЛУЧАЙHЫХ ЧИСЕЛ   Ianos Gnatiuc   09 Oct 2002 03:58:49 
Архивное /ru.algorithms/18133da2f66d.html, оценка 3 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional