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

📄 rng.texi

📁 该文件为c++的数学函数库!是一个非常有用的编程工具.它含有各种数学函数,为科学计算、工程应用等程序编写提供方便!
💻 TEXI
📖 第 1 页 / 共 4 页
字号:
@math{2^19937 - 1} (about @c{$10^{6000}$}@math{10^6000}) and isequi-distributed in 623 dimensions.  It has passed the @sc{diehard}statistical tests.  It uses 624 words of state per generator and iscomparable in speed to the other generators.  The original generator useda default seed of 4357 and choosing @var{s} equal to zero in@code{gsl_rng_set} reproduces this.For more information see,@itemize @asis@itemMakoto Matsumoto and Takuji Nishimura, "Mersenne Twister: A623-dimensionally equidistributed uniform pseudorandom numbergenerator". @cite{ACM Transactions on Modeling and ComputerSimulation}, Vol. 8, No. 1 (Jan. 1998), Pages 3-30@end itemize@noindentThe generator @code{gsl_rng_19937} uses the second revision of theseeding procedure published by the two authors above in 2002.  Theoriginal seeding procedures could cause spurious artifacts for some seedvalues. They are still available through the alternate generators@code{gsl_rng_mt19937_1999} and @code{gsl_rng_mt19937_1998}.@end deffn@deffn {Generator} gsl_rng_ranlxs0@deffnx {Generator} gsl_rng_ranlxs1@deffnx {Generator} gsl_rng_ranlxs2@cindex RANLXS random number generatorThe generator @code{ranlxs0} is a second-generation version of the@sc{ranlux} algorithm of L@"uscher, which produces "luxury randomnumbers".  This generator provides single precision output (24 bits) atthree luxury levels @code{ranlxs0}, @code{ranlxs1} and @code{ranlxs2}.It uses double-precision floating point arithmetic internally and can besignificantly faster than the integer version of @code{ranlux},particularly on 64-bit architectures.  The period of the generator isabout @c{$10^{171}$} @math{10^171}.  The algorithm has mathematically proven properties andcan provide truly decorrelated numbers at a known level of randomness.The higher luxury levels provide additional decorrelation between samplesas an additional safety margin.@end deffn@deffn {Generator} gsl_rng_ranlxd1@deffnx {Generator} gsl_rng_ranlxd2@cindex RANLXD random number generatorThese generators produce double precision output (48 bits) from the@sc{ranlxs} generator.  The library provides two luxury levels@code{ranlxd1} and @code{ranlxd2}.@end deffn@deffn {Generator} gsl_rng_ranlux@deffnx {Generator} gsl_rng_ranlux389@cindex RANLUX random number generatorThe @code{ranlux} generator is an implementation of the originalalgorithm developed by L@"uscher.  It uses alagged-fibonacci-with-skipping algorithm to produce "luxury randomnumbers".  It is a 24-bit generator, originally designed forsingle-precision IEEE floating point numbers.  This implementation isbased on integer arithmetic, while the second-generation versions@sc{ranlxs} and @sc{ranlxd} described above provide floating-pointimplementations which will be faster on many platforms.The period of the generator is about @c{$10^{171}$} @math{10^171}.  The algorithm has mathematically proven properties andit can provide truly decorrelated numbers at a known level ofrandomness.  The default level of decorrelation recommended by L@"uscheris provided by @code{gsl_rng_ranlux}, while @code{gsl_rng_ranlux389}gives the highest level of randomness, with all 24 bits decorrelated.Both types of generator use 24 words of state per generator.For more information see,@itemize @asis@itemM. L@"uscher, "A portable high-quality random number generator forlattice field theory calculations", @cite{Computer PhysicsCommunications}, 79 (1994) 100-110.@itemF. James, "RANLUX: A Fortran implementation of the high-qualitypseudo-random number generator of L@"uscher", @cite{Computer PhysicsCommunications}, 79 (1994) 111-114@end itemize@end deffn@deffn {Generator} gsl_rng_cmrg@cindex CMRG, combined multiple recursive random number generatorThis is a combined multiple recursive generator by L'Ecuyer. Its sequence is,@tex\beforedisplay$$z_n = (x_n - y_n) \,\hbox{mod}\, m_1$$\afterdisplay@end tex@ifinfo@examplez_n = (x_n - y_n) mod m_1@end example@end ifinfo@noindentwhere the two underlying generators @math{x_n} and @math{y_n} are,@tex\beforedisplay$$\eqalign{ x_n & = (a_1 x_{n-1} + a_2 x_{n-2} + a_3 x_{n-3}) \,\hbox{mod}\, m_1 \cry_n & = (b_1 y_{n-1} + b_2 y_{n-2} + b_3 y_{n-3}) \,\hbox{mod}\, m_2}$$\afterdisplay@end tex@ifinfo@examplex_n = (a_1 x_@{n-1@} + a_2 x_@{n-2@} + a_3 x_@{n-3@}) mod m_1y_n = (b_1 y_@{n-1@} + b_2 y_@{n-2@} + b_3 y_@{n-3@}) mod m_2@end example@end ifinfo@noindentwith coefficients @math{a_1 = 0}, @math{a_2 = 63308}, @math{a_3 = -183326},@math{b_1 = 86098}, @math{b_2 = 0},@math{b_3 = -539608},and moduli @c{$m_1 = 2^{31} - 1 = 2147483647$} @math{m_1 = 2^31 - 1 = 2147483647}and @c{$m_2 = 2145483479$}@math{m_2 = 2145483479}.The period of this generator is @c{$2^{205}$}@math{2^205} (about @c{$10^{61}$}@math{10^61}).  It uses6 words of state per generator.  For more information see,@itemize @asis@itemP. L'Ecuyer, "Combined Multiple Recursive Random NumberGenerators," @cite{Operations Research}, 44, 5 (1996), 816--822.@end itemize@end deffn@deffn {Generator} gsl_rng_mrg@cindex MRG, multiple recursive random number generatorThis is a fifth-order multiple recursive generator by L'Ecuyer, Blouinand Coutre.  Its sequence is,@tex\beforedisplay$$x_n = (a_1 x_{n-1} + a_5 x_{n-5}) \,\hbox{mod}\, m$$\afterdisplay@end tex@ifinfo@examplex_n = (a_1 x_@{n-1@} + a_5 x_@{n-5@}) mod m@end example@end ifinfo@noindentwith @math{a_1 = 107374182}, @math{a_2 = a_3 = a_4 = 0}, @math{a_5 = 104480}and @c{$m = 2^{31}-1$}@math{m = 2^31 - 1}.The period of this generator is about @c{$10^{46}$}@math{10^46}.  It uses 5 wordsof state per generator.  More information can be found in the followingpaper,@itemize @asis@itemP. L'Ecuyer, F. Blouin, and R. Coutre, "A search for good multiplerecursive random number generators", @cite{ACM Transactions on Modeling andComputer Simulation} 3, 87-98 (1993).@end itemize@end deffn@deffn {Generator} gsl_rng_taus@deffnx {Generator} gsl_rng_taus2@cindex Tausworthe random number generatorThis is a maximally equidistributed combined Tausworthe generator byL'Ecuyer.  The sequence is,@tex\beforedisplay$$x_n = (s^1_n \oplus s^2_n \oplus s^3_n) $$\afterdisplay@end tex@ifinfo@examplex_n = (s1_n ^^ s2_n ^^ s3_n) @end example@end ifinfo@noindentwhere,@tex\beforedisplay$$\eqalign{s^1_{n+1} &= (((s^1_n \& 4294967294)\ll 12) \oplus (((s^1_n\ll 13) \oplus s^1_n)\gg 19)) \crs^2_{n+1} &= (((s^2_n \& 4294967288)\ll 4) \oplus (((s^2_n\ll 2) \oplus s^2_n)\gg 25)) \crs^3_{n+1} &= (((s^3_n \& 4294967280)\ll 17) \oplus (((s^3_n\ll 3) \oplus s^3_n)\gg 11))}$$\afterdisplay@end tex@ifinfo@examples1_@{n+1@} = (((s1_n&4294967294)<<12)^^(((s1_n<<13)^^s1_n)>>19))s2_@{n+1@} = (((s2_n&4294967288)<< 4)^^(((s2_n<< 2)^^s2_n)>>25))s3_@{n+1@} = (((s3_n&4294967280)<<17)^^(((s3_n<< 3)^^s3_n)>>11))@end example@end ifinfo@noindentcomputed modulo @c{$2^{32}$}@math{2^32}.  In the formulas above @c{$\oplus$}@math{^^}denotes ``exclusive-or''.  Note that the algorithm relies on the propertiesof 32-bit unsigned integers and has been implemented using a bitmaskof @code{0xFFFFFFFF} to make it work on 64 bit machines.The period of this generator is @c{$2^{88}$}@math{2^88} (about@c{$10^{26}$}@math{10^26}).  It uses 3 words of state per generator.  For moreinformation see,@itemize @asis@itemP. L'Ecuyer, "Maximally Equidistributed Combined TauswortheGenerators", @cite{Mathematics of Computation}, 65, 213 (1996), 203--213.@end itemize@noindentThe generator @code{gsl_rng_taus2} uses the same algorithm as@code{gsl_rng_taus} but with an improved seeding procedure described inthe paper,@itemize @asis@itemP. L'Ecuyer, "Tables of Maximally Equidistributed Combined LFSRGenerators", @cite{Mathematics of Computation}, 68, 225 (1999), 261--269@end itemize@noindentThe generator @code{gsl_rng_taus2} should now be used in preference to@code{gsl_rng_taus}.@end deffn@deffn {Generator} gsl_rng_gfsr4@cindex Four-tap Generalized Feedback Shift RegisterThe @code{gfsr4} generator is like a lagged-fibonacci generator, and produces each number as an @code{xor}'d sum of four previous values.@tex\beforedisplay$$r_n = r_{n-A} \oplus r_{n-B} \oplus r_{n-C} \oplus r_{n-D}$$\afterdisplay@end tex@ifinfo@exampler_n = r_@{n-A@} ^^ r_@{n-B@} ^^ r_@{n-C@} ^^ r_@{n-D@}@end example@end ifinfoZiff (ref below) notes that "it is now widely known" that two-tapregisters (such as R250, which is described below)have serious flaws, the most obvious one being the three-pointcorrelation that comes from the definition of the generator.  Nicemathematical properties can be derived for GFSR's, and numerics bearsout the claim that 4-tap GFSR's with appropriately chosen offsets are asrandom as can be measured, using the author's test.This implementation uses the values suggested the example on p392 ofZiff's article: @math{A=471}, @math{B=1586}, @math{C=6988}, @math{D=9689}.If the offsets are appropriately chosen (such as the one ones in thisimplementation), then the sequence is said to be maximal; that meansthat the period is @math{2^D - 1}, where @math{D} is the longest lag.(It is one less than @math{2^D} because it is not permitted to have allzeros in the @code{ra[]} array.)  For this implementation with@math{D=9689} that works out to about @c{$10^{2917}$}@math{10^2917}.Note that the implementation of this generator using a 32-bitinteger amounts to 32 parallel implementations of one-bitgenerators.  One consequence of this is that the period of this32-bit generator is the same as for the one-bit generator.Moreover, this inedpendence means that all 32-bit patterns areequally likely, and in particular that 0 is an allowed randomvalue.  (We are grateful to Heiko Bauke for clarifying for us theseproperties of GFSR random number generators.)For more information see,@itemize @asis@itemRobert M. Ziff, "Four-tap shift-register-sequence random-number generators", @cite{Computers in Physics}, 12(4), Jul/Aug1998, pp 385-392.@end itemize@end deffn@node Unix random number generators@section Unix random number generatorsThe standard Unix random number generators @code{rand}, @code{random}and @code{rand48} are provided as part of GSL. Although thesegenerators are widely available individually often they aren't allavailable on the same platform.  This makes it difficult to writeportable code using them and so we have included the complete set ofUnix generators in GSL for convenience.  Note that these generatorsdon't produce high-quality randomness and aren't suitable for workrequiring accurate statistics.  However, if you won't be measuringstatistical quantities and just want to introduce some variation intoyour program then these generators are quite acceptable.@cindex BSD random number generator, rand@cindex Unix random number generators, rand@cindex Unix random number generators, rand48@deffn {Generator} gsl_rng_rand@cindex BSD random number generatorThis is the BSD @code{rand()} generator.  Its sequence is@tex\beforedisplay$$x_{n+1} = (a x_n + c) \,\hbox{mod}\, m$$\afterdisplay@end tex@ifinfo@examplex_@{n+1@} = (a x_n + c) mod m@end example@end ifinfo@noindentwith @math{a = 1103515245}, @math{c = 12345} and @c{$m = 2^{31}$}@math{m = 2^31}.The seed specifies the initial value, @math{x_1}.  The period of thisgenerator is @c{$2^{31}$}@math{2^31}, and it uses 1 word of storage per

⌨️ 快捷键说明

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