⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rng.texi

📁 用于VC.net的gsl的lib库文件包
💻 TEXI
📖 第 1 页 / 共 4 页
字号:
generator.
@end deffn

@deffn {Generator} gsl_rng_random_bsd
@deffnx {Generator} gsl_rng_random_libc5
@deffnx {Generator} gsl_rng_random_glibc2
These generators implement the @code{random()} family of functions, a
set of linear feedback shift register generators originally used in BSD
Unix.  There are several versions of @code{random()} in use today: the
original BSD version (e.g. on SunOS4), a libc5 version (found on
older GNU/Linux systems) and a glibc2 version.  Each version uses a
different seeding procedure, and thus produces different sequences.

The original BSD routines accepted a variable length buffer for the
generator state, with longer buffers providing higher-quality
randomness.  The @code{random()} function implemented algorithms for
buffer lengths of 8, 32, 64, 128 and 256 bytes, and the algorithm with
the largest length that would fit into the user-supplied buffer was
used.  To support these algorithms additional generators are available
with the following names,

@example
gsl_rng_random8_bsd
gsl_rng_random32_bsd
gsl_rng_random64_bsd
gsl_rng_random128_bsd
gsl_rng_random256_bsd
@end example

@noindent
where the numeric suffix indicates the buffer length.  The original BSD
@code{random} function used a 128-byte default buffer and so
@code{gsl_rng_random_bsd} has been made equivalent to
@code{gsl_rng_random128_bsd}.  Corresponding versions of the @code{libc5}
and @code{glibc2} generators are also available, with the names
@code{gsl_rng_random8_libc5}, @code{gsl_rng_random8_glibc2}, etc.
@end deffn

@deffn {Generator} gsl_rng_rand48
@cindex rand48 random number generator
This is the Unix @code{rand48} generator.  Its sequence is

@tex
\beforedisplay
$$
x_{n+1} = (a x_n + c) \,\hbox{mod}\, m
$$
\afterdisplay
@end tex
@ifinfo
@example
x_@{n+1@} = (a x_n + c) mod m
@end example
@end ifinfo
@noindent
defined on 48-bit unsigned integers with 
@math{a = 25214903917}, 
@math{c = 11} and 
@c{$m = 2^{48}$} 
@math{m = 2^48}. 
The seed specifies the upper 32 bits of the initial value, @math{x_1},
with the lower 16 bits set to @code{0x330E}.  The function
@code{gsl_rng_get} returns the upper 32 bits from each term of the
sequence.  This does not have a direct parallel in the original
@code{rand48} functions, but forcing the result to type @code{long int}
reproduces the output of @code{mrand48}.  The function
@code{gsl_rng_uniform} uses the full 48 bits of internal state to return
the double precision number @math{x_n/m}, which is equivalent to the
function @code{drand48}.  Note that some versions of the GNU C Library
contained a bug in @code{mrand48} function which caused it to produce
different results (only the lower 16-bits of the return value were set).
@end deffn

@node Other random number generators
@section Other random number generators

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.

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, 
@c{$2^{31}$}
@math{2^31} or 
@c{$2^{32}$}
@math{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.

@deffn {Generator} gsl_rng_ranf
@cindex RANF random number generator
@cindex CRAY random number generator, RANF
This is the CRAY random number generator @code{RANF}.  Its sequence is

@tex
\beforedisplay
$$
x_{n+1} = (a x_n) \,\hbox{mod}\, m
$$
\afterdisplay
@end tex
@ifinfo
@example
x_@{n+1@} = (a x_n) mod m
@end example
@end ifinfo
@noindent
defined on 48-bit unsigned integers with @math{a = 44485709377909} and
@c{$m = 2^{48}$}
@math{m = 2^48}.  The seed specifies the lower
32 bits of the initial value, 
@math{x_1}, with the lowest bit set to
prevent the seed taking an even value.  The upper 16 bits of 
@math{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.

The generator compatibile with the CRAY MATHLIB routine RANF. It
produces double precision floating point numbers which should be
identical to those from the original RANF.

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 @math{a} mod @math{m}.  This is done for compatibility with
the original CRAY implementation.

Note that you can only seed the generator with integers up to
@c{$2^{32}$}
@math{2^32}, while the original CRAY implementation uses
non-portable wide integers which can cover all 
@c{$2^{48}$}
@math{2^48} states of the generator.

The function @code{gsl_rng_get} returns the upper 32 bits from each term
of the sequence.  The function @code{gsl_rng_uniform} uses the full 48
bits to return the double precision number @math{x_n/m}.

The period of this generator is @c{$2^{46}$}
@math{2^46}.
@end deffn

@deffn {Generator} gsl_rng_ranmar
@cindex RANMAR random number generator
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.
@end deffn

@deffn {Generator} gsl_rng_r250
@cindex shift-register random number generator
@cindex R250 shift-register random number generator
This is the shift-register generator of Kirkpatrick and Stoll.  The
sequence is

@tex
\beforedisplay
$$ 
x_n = x_{n-103} \oplus x_{n-250}
$$
\afterdisplay
@end tex
@ifinfo
@example
x_n = x_@{n-103@} ^^ x_@{n-250@}
@end example
@end ifinfo
@noindent
where 
@c{$\oplus$}
@math{^^} denote ``exclusive-or'', defined on
32-bit words.  The period of this generator is about @c{$2^{250}$}
@math{2^250} and it
uses 250 words of state per generator.

For more information see,
@itemize @asis
@item
S. Kirkpatrick and E. Stoll, "A very fast shift-register sequence random
number generator", @cite{Journal of Computational Physics}, 40, 517-526
(1981)
@end itemize
@end deffn

@deffn {Generator} gsl_rng_tt800
@cindex TT800 random number generator
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 
@c{$2^{800}$}
@math{2^800} and uses 33 words of storage
per generator.

For more information see,
@itemize @asis
@item
Makoto Matsumoto and Yoshiharu Kurita, "Twisted GFSR Generators
II", @cite{ACM Transactions on Modelling and Computer Simulation},
Vol. 4, No. 3, 1994, pages 254-266.
@end itemize
@end deffn

@comment The following generators are included only for historical reasons, so
@comment that you can reproduce results from old programs which might have used
@comment them.  These generators should not be used for real simulations since
@comment they have poor statistical properties by modern standards.

@deffn {Generator} gsl_rng_vax
@cindex VAX random number generator
This is the VAX generator @code{MTH$RANDOM}.  Its sequence is,

@tex
\beforedisplay
$$
x_{n+1} = (a x_n + c) \,\hbox{mod}\, m
$$
\afterdisplay
@end tex
@ifinfo
@example
x_@{n+1@} = (a x_n + c) mod m
@end example
@end ifinfo
@noindent
with 
@math{a = 69069}, @math{c = 1} and 
@c{$m = 2^{32}$}
@math{m = 2^32}.  The seed specifies the initial value, 
@math{x_1}.  The
period of this generator is 
@c{$2^{32}$}
@math{2^32} and it uses 1 word of storage per
generator.
@end deffn

@deffn {Generator} gsl_rng_transputer
This is the random number generator from the INMOS Transputer
Development system.  Its sequence is,

@tex
\beforedisplay
$$
x_{n+1} = (a x_n) \,\hbox{mod}\, m
$$
\afterdisplay
@end tex
@ifinfo
@example
x_@{n+1@} = (a x_n) mod m
@end example
@end ifinfo
@noindent
with @math{a = 1664525} and 
@c{$m = 2^{32}$}
@math{m = 2^32}.
The seed specifies the initial value, 
@c{$x_1$}
@math{x_1}.
@end deffn

@deffn {Generator} gsl_rng_randu
@cindex RANDU random number generator
This is the IBM @code{RANDU} generator.  Its sequence is

@tex
\beforedisplay
$$
x_{n+1} = (a x_n) \,\hbox{mod}\, m
$$
\afterdisplay
@end tex
@ifinfo
@example
x_@{n+1@} = (a x_n) mod m
@end example
@end ifinfo
@noindent
with @math{a = 65539} and 
@c{$m = 2^{31}$}
@math{m = 2^31}.  The
seed specifies the initial value, 
@math{x_1}.  The period of this
generator was only 
@c{$2^{29}$}
@math{2^29}.  It has become a textbook example of a
poor generator.
@end deffn

@deffn {Generator} gsl_rng_minstd
@cindex RANMAR random number generator
This is Park and Miller's "minimal standard" @sc{minstd} generator, a
simple linear congruence which takes care to avoid the major pitfalls of
such algorithms.  Its sequence is,

@tex
\beforedisplay
$$
x_{n+1} = (a x_n) \,\hbox{mod}\, m
$$
\afterdisplay
@end tex
@ifinfo
@example
x_@{n+1@} = (a x_n) mod m
@end example
@end ifinfo
@noindent
with @math{a = 16807} and 
@c{$m = 2^{31} - 1 = 2147483647$}
@math{m = 2^31 - 1 = 2147483647}. 
The seed specifies the initial value, 
@c{$x_1$}
@math{x_1}.  The period of this
generator is about 
@c{$2^{31}$}
@math{2^31}.

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).

For more information see,
@itemize @asis
@item
Park and Miller, "Random Number Generators: Good ones are hard to find",
@cite{Communications of the ACM}, October 1988, Volume 31, No 10, pages
1192-1201.
@end itemize
@end deffn

@deffn {Generator} gsl_rng_uni
@deffnx {Generator} gsl_rng_uni32
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}.  The original source code is available from NETLIB.
@end deffn

@deffn {Generator} gsl_rng_slatec
This is the SLATEC random number generator RAND. It is ancient.  The
original source code is available from NETLIB.
@end deffn


@deffn {Generator} gsl_rng_zuf
This is the ZUFALL lagged Fibonacci series generator of Peterson.  Its
sequence is,

@tex
\beforedisplay
$$ 
\eqalign{
t &= u_{n-273} + u_{n-607} \cr
u_n  &= t - \hbox{floor}(t)
}
$$
\afterdisplay
@end tex
@ifinfo
@example
t = u_@{n-273@} + u_@{n-607@}
u_n  = t - floor(t)
@end example
@end ifinfo

The original source code is available from NETLIB.  For more information

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -