1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
|
<html lang="en">
<head>
<title>Other random number generators - GNU Scientific Library -- Reference Manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Scientific Library -- Reference Manual">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Random-Number-Generation.html" title="Random Number Generation">
<link rel="prev" href="Unix-random-number-generators.html" title="Unix random number generators">
<link rel="next" href="Random-Number-Generator-Performance.html" title="Random Number Generator Performance">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 The GSL Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'' and ``Free Software
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
and with the Back-Cover Text being (a) (see below). A copy of the
license is included in the section entitled ``GNU Free Documentation
License''.
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
GNU Manual, like GNU software.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Other-random-number-generators"></a>
Next: <a rel="next" accesskey="n" href="Random-Number-Generator-Performance.html">Random Number Generator Performance</a>,
Previous: <a rel="previous" accesskey="p" href="Unix-random-number-generators.html">Unix random number generators</a>,
Up: <a rel="up" accesskey="u" href="Random-Number-Generation.html">Random Number Generation</a>
<hr>
</div>
<h3 class="section">17.11 Other random number generators</h3>
<p>The generators in this section are provided for compatibility with
existing libraries. If you are converting an existing program to use GSL
then you can select these generators to check your new implementation
against the original one, using the same random number generator. After
verifying that your new program reproduces the original results you can
then switch to a higher-quality generator.
<p>Note that most of the generators in this section are based on single
linear congruence relations, which are the least sophisticated type of
generator. In particular, linear congruences have poor properties when
used with a non-prime modulus, as several of these routines do (e.g.
with a power of two modulus,
<!-- {$2^{31}$} -->
2^31 or
<!-- {$2^{32}$} -->
2^32). This
leads to periodicity in the least significant bits of each number,
with only the higher bits having any randomness. Thus if you want to
produce a random bitstream it is best to avoid using the least
significant bits.
<div class="defun">
— Generator: <b>gsl_rng_ranf</b><var><a name="index-gsl_005frng_005franf-1527"></a></var><br>
<blockquote><p><a name="index-RANF-random-number-generator-1528"></a><a name="index-CRAY-random-number-generator_002c-RANF-1529"></a>This is the CRAY random number generator <code>RANF</code>. Its sequence is
<pre class="example"> x_{n+1} = (a x_n) mod m
</pre>
<p class="noindent">defined on 48-bit unsigned integers with a = 44485709377909 and
<!-- {$m = 2^{48}$} -->
m = 2^48. The seed specifies the lower
32 bits of the initial value,
x_1, with the lowest bit set to
prevent the seed taking an even value. The upper 16 bits of
x_1
are set to 0. A consequence of this procedure is that the pairs of seeds
2 and 3, 4 and 5, etc produce the same sequences.
<p>The generator compatible with the CRAY MATHLIB routine RANF. It
produces double precision floating point numbers which should be
identical to those from the original RANF.
<p>There is a subtlety in the implementation of the seeding. The initial
state is reversed through one step, by multiplying by the modular
inverse of a mod m. This is done for compatibility with
the original CRAY implementation.
<p>Note that you can only seed the generator with integers up to
<!-- {$2^{32}$} -->
2^32, while the original CRAY implementation uses
non-portable wide integers which can cover all
<!-- {$2^{48}$} -->
2^48 states of the generator.
<p>The function <code>gsl_rng_get</code> returns the upper 32 bits from each term
of the sequence. The function <code>gsl_rng_uniform</code> uses the full 48
bits to return the double precision number x_n/m.
<p>The period of this generator is <!-- {$2^{46}$} -->
2^46.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_ranmar</b><var><a name="index-gsl_005frng_005franmar-1530"></a></var><br>
<blockquote><p><a name="index-RANMAR-random-number-generator-1531"></a>This is the RANMAR lagged-fibonacci generator of Marsaglia, Zaman and
Tsang. It is a 24-bit generator, originally designed for
single-precision IEEE floating point numbers. It was included in the
CERNLIB high-energy physics library.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_r250</b><var><a name="index-gsl_005frng_005fr250-1532"></a></var><br>
<blockquote><p><a name="index-shift_002dregister-random-number-generator-1533"></a><a name="index-R250-shift_002dregister-random-number-generator-1534"></a>This is the shift-register generator of Kirkpatrick and Stoll. The
sequence is based on the recurrence
<pre class="example"> x_n = x_{n-103} ^^ x_{n-250}
</pre>
<p class="noindent">where
<!-- {$\oplus$} -->
^^ denotes “exclusive-or”, defined on
32-bit words. The period of this generator is about <!-- {$2^{250}$} -->
2^250 and it
uses 250 words of state per generator.
<p>For more information see,
<ul>
<li>S. Kirkpatrick and E. Stoll, “A very fast shift-register sequence random
number generator”, <cite>Journal of Computational Physics</cite>, 40, 517–526
(1981)
</ul>
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_tt800</b><var><a name="index-gsl_005frng_005ftt800-1535"></a></var><br>
<blockquote><p><a name="index-TT800-random-number-generator-1536"></a>This is an earlier version of the twisted generalized feedback
shift-register generator, and has been superseded by the development of
MT19937. However, it is still an acceptable generator in its own
right. It has a period of
<!-- {$2^{800}$} -->
2^800 and uses 33 words of storage
per generator.
<p>For more information see,
<ul>
<li>Makoto Matsumoto and Yoshiharu Kurita, “Twisted GFSR Generators
II”, <cite>ACM Transactions on Modelling and Computer Simulation</cite>,
Vol. 4, No. 3, 1994, pages 254–266.
</ul>
</p></blockquote></div>
<!-- The following generators are included only for historical reasons, so -->
<!-- that you can reproduce results from old programs which might have used -->
<!-- them. These generators should not be used for real simulations since -->
<!-- they have poor statistical properties by modern standards. -->
<div class="defun">
— Generator: <b>gsl_rng_vax</b><var><a name="index-gsl_005frng_005fvax-1537"></a></var><br>
<blockquote><p><a name="index-VAX-random-number-generator-1538"></a>This is the VAX generator <code>MTH$RANDOM</code>. Its sequence is,
<pre class="example"> x_{n+1} = (a x_n + c) mod m
</pre>
<p class="noindent">with
a = 69069, c = 1 and
<!-- {$m = 2^{32}$} -->
m = 2^32. The seed specifies the initial value,
x_1. The
period of this generator is
<!-- {$2^{32}$} -->
2^32 and it uses 1 word of storage per
generator.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_transputer</b><var><a name="index-gsl_005frng_005ftransputer-1539"></a></var><br>
<blockquote><p>This is the random number generator from the INMOS Transputer
Development system. Its sequence is,
<pre class="example"> x_{n+1} = (a x_n) mod m
</pre>
<p class="noindent">with a = 1664525 and
<!-- {$m = 2^{32}$} -->
m = 2^32.
The seed specifies the initial value,
<!-- {$x_1$} -->
x_1.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_randu</b><var><a name="index-gsl_005frng_005frandu-1540"></a></var><br>
<blockquote><p><a name="index-RANDU-random-number-generator-1541"></a>This is the IBM <code>RANDU</code> generator. Its sequence is
<pre class="example"> x_{n+1} = (a x_n) mod m
</pre>
<p class="noindent">with a = 65539 and
<!-- {$m = 2^{31}$} -->
m = 2^31. The
seed specifies the initial value,
x_1. The period of this
generator was only
<!-- {$2^{29}$} -->
2^29. It has become a textbook example of a
poor generator.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_minstd</b><var><a name="index-gsl_005frng_005fminstd-1542"></a></var><br>
<blockquote><p><a name="index-RANMAR-random-number-generator-1543"></a>This is Park and Miller's “minimal standard” <span class="sc">minstd</span> generator, a
simple linear congruence which takes care to avoid the major pitfalls of
such algorithms. Its sequence is,
<pre class="example"> x_{n+1} = (a x_n) mod m
</pre>
<p class="noindent">with a = 16807 and
<!-- {$m = 2^{31} - 1 = 2147483647$} -->
m = 2^31 - 1 = 2147483647.
The seed specifies the initial value,
<!-- {$x_1$} -->
x_1. The period of this
generator is about
<!-- {$2^{31}$} -->
2^31.
<p>This generator is used in the IMSL Library (subroutine RNUN) and in
MATLAB (the RAND function). It is also sometimes known by the acronym
“GGL” (I'm not sure what that stands for).
<p>For more information see,
<ul>
<li>Park and Miller, “Random Number Generators: Good ones are hard to find”,
<cite>Communications of the ACM</cite>, October 1988, Volume 31, No 10, pages
1192–1201.
</ul>
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_uni</b><var><a name="index-gsl_005frng_005funi-1544"></a></var><br>
— Generator: <b>gsl_rng_uni32</b><var><a name="index-gsl_005frng_005funi32-1545"></a></var><br>
<blockquote><p>This is a reimplementation of the 16-bit SLATEC random number generator
RUNIF. A generalization of the generator to 32 bits is provided by
<code>gsl_rng_uni32</code>. The original source code is available from NETLIB.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_slatec</b><var><a name="index-gsl_005frng_005fslatec-1546"></a></var><br>
<blockquote><p>This is the SLATEC random number generator RAND. It is ancient. The
original source code is available from NETLIB.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_zuf</b><var><a name="index-gsl_005frng_005fzuf-1547"></a></var><br>
<blockquote><p>This is the ZUFALL lagged Fibonacci series generator of Peterson. Its
sequence is,
<pre class="example"> t = u_{n-273} + u_{n-607}
u_n = t - floor(t)
</pre>
<p>The original source code is available from NETLIB. For more information
see,
<ul>
<li>W. Petersen, “Lagged Fibonacci Random Number Generators for the NEC
SX-3”, <cite>International Journal of High Speed Computing</cite> (1994).
</ul>
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_knuthran2</b><var><a name="index-gsl_005frng_005fknuthran2-1548"></a></var><br>
<blockquote><p>This is a second-order multiple recursive generator described by Knuth
in <cite>Seminumerical Algorithms</cite>, 3rd Ed., page 108. Its sequence is,
<pre class="example"> x_n = (a_1 x_{n-1} + a_2 x_{n-2}) mod m
</pre>
<p class="noindent">with
a_1 = 271828183,
a_2 = 314159269,
and
<!-- {$m = 2^{31}-1$} -->
m = 2^31 - 1.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_knuthran2002</b><var><a name="index-gsl_005frng_005fknuthran2002-1549"></a></var><br>
— Generator: <b>gsl_rng_knuthran</b><var><a name="index-gsl_005frng_005fknuthran-1550"></a></var><br>
<blockquote><p>This is a second-order multiple recursive generator described by Knuth
in <cite>Seminumerical Algorithms</cite>, 3rd Ed., Section 3.6. Knuth
provides its C code. The updated routine <code>gsl_rng_knuthran2002</code>
is from the revised 9th printing and corrects some weaknesses in the
earlier version, which is implemented as <code>gsl_rng_knuthran</code>.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_borosh13</b><var><a name="index-gsl_005frng_005fborosh13-1551"></a></var><br>
— Generator: <b>gsl_rng_fishman18</b><var><a name="index-gsl_005frng_005ffishman18-1552"></a></var><br>
— Generator: <b>gsl_rng_fishman20</b><var><a name="index-gsl_005frng_005ffishman20-1553"></a></var><br>
— Generator: <b>gsl_rng_lecuyer21</b><var><a name="index-gsl_005frng_005flecuyer21-1554"></a></var><br>
— Generator: <b>gsl_rng_waterman14</b><var><a name="index-gsl_005frng_005fwaterman14-1555"></a></var><br>
<blockquote><p>These multiplicative generators are taken from Knuth's
<cite>Seminumerical Algorithms</cite>, 3rd Ed., pages 106–108. Their sequence
is,
<pre class="example"> x_{n+1} = (a x_n) mod m
</pre>
<p class="noindent">where the seed specifies the initial value, <!-- {$x_1$} -->
x_1.
The parameters a and m are as follows,
Borosh-Niederreiter:
a = 1812433253, <!-- {$m = 2^{32}$} -->
m = 2^32,
Fishman18:
a = 62089911,
<!-- {$m = 2^{31}-1$} -->
m = 2^31 - 1,
Fishman20:
a = 48271,
<!-- {$m = 2^{31}-1$} -->
m = 2^31 - 1,
L'Ecuyer:
a = 40692,
<!-- {$m = 2^{31}-249$} -->
m = 2^31 - 249,
Waterman:
a = 1566083941,
<!-- {$m = 2^{32}$} -->
m = 2^32.
</p></blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_fishman2x</b><var><a name="index-gsl_005frng_005ffishman2x-1556"></a></var><br>
<blockquote><p>This is the L'Ecuyer–Fishman random number generator. It is taken from
Knuth's <cite>Seminumerical Algorithms</cite>, 3rd Ed., page 108. Its sequence
is,
<pre class="example"> z_{n+1} = (x_n - y_n) mod m
</pre>
<p class="noindent">with <!-- {$m = 2^{31}-1$} -->
m = 2^31 - 1.
x_n and y_n are given by the <code>fishman20</code>
and <code>lecuyer21</code> algorithms.
The seed specifies the initial value,
<!-- {$x_1$} -->
x_1.
</blockquote></div>
<div class="defun">
— Generator: <b>gsl_rng_coveyou</b><var><a name="index-gsl_005frng_005fcoveyou-1557"></a></var><br>
<blockquote><p>This is the Coveyou random number generator. It is taken from Knuth's
<cite>Seminumerical Algorithms</cite>, 3rd Ed., Section 3.2.2. Its sequence
is,
<pre class="example"> x_{n+1} = (x_n (x_n + 1)) mod m
</pre>
<p class="noindent">with <!-- {$m = 2^{32}$} -->
m = 2^32.
The seed specifies the initial value,
<!-- {$x_1$} -->
x_1.
</p></blockquote></div>
<hr>The GNU Scientific Library - a free numerical library licensed under the GNU GPL<br>Back to the <a href="/software/gsl/">GNU Scientific Library Homepage</a></body></html>
|