正在加载图片...
286 Chapter 7.Random Numbers is indicative of the relative timings,for typical machines,of the various uniform generators discussed in this section,plus ran4 from $7.5.Smaller values in the table indicate faster generators.The generators rangd1 and rangd2 refer to the "quick and dirty"generators immediately above. Generator Relative Execution Time ran0 三1.0 ran1 ≈1.3 ran2 ≈2.0 83 ≈0.6 granted for ran3 ranqd1 ≈0.10 (including this one) 19881992 ranqd2 ≈0.25 111800.872 /Cambridge ran4 ≈4.0 On balance.we recommend ran1 for general use.It is portable,based on Park and Miller's Minimal Standard generator with an additional shuffle,and has no C0anA/9N from NUMERICAL RECIPES IN (Nort server America computer known (to us)flaws other than period exhaustion. ART If you are generating more than 100,000,000 random numbers in a single calculation (that is,more than about 5%of ran1's period),we recommend the use 9 Progra of ran2,with its much longer period. Knuth's subtractive routine ran3 seems to be the timing winner among portable OF SCIENTIFIC( routines.Unfortunately the subtractive method is not so well studied,and not a standard.We like to keep ran3 in reserve for a"second opinion,"substituting it when 6 we suspect another generator of introducing unwanted correlations into a calculation. The routine ran4 generates extremely good random deviates,and has some other nice properties,but it is slow.See 87.5 for discussion. Finally,the quick and dirty in-line generators rangd1 and rangd2 are very fast. but they are somewhat machine dependent,and at best only as good as a 32-bit linear Fuurggoglrion Numerical Recipes 10-621 congruential generator ever is-in our view not good enough in many situations. We would use these only in very special cases,where speed is critical. 43106 (outside CITED REFERENCES AND FURTHER READING: Park,S.K.,and Miller,K.W.1988,Communications of the ACM,vol.31,pp.1192-1201.[1] North Software. Schrage,L.1979,ACM Transactions on Mathematical Software,vol.5,pp.132-138.[2] Bratley,P.,Fox,B.L.,and Schrage,E.L.1983,A Guide to Simulation (New York:Springer- Verlag).[3] visit website machine Knuth,D.E.1981,Seminumerical Algorithms,2nd ed.,vol.2 of The Art of Computer Programming (Reading.MA:Addison-Wesley).3.2-3.3.[4] Kahaner,D.,Moler,C.,and Nash,S.1989,Numerica/Methods and Software(Englewood Cliffs, NJ:Prentice Hall),Chapter 10.[5] L'Ecuyer,P.1988,Communications of the ACM,vol.31,pp.742-774.[6] Forsythe,G.E.,Malcolm,M.A.,and Moler,C.B.1977,Computer Methods for Mathematical Computations (Englewood Cliffs,NJ:Prentice-Hall),Chapter 10.286 Chapter 7. Random Numbers Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). is indicative of the relative timings, for typical machines, of the various uniform generators discussed in this section, plus ran4 from §7.5. Smaller values in the table indicate faster generators. The generators ranqd1 and ranqd2 refer to the “quick and dirty” generators immediately above. Generator Relative Execution Time ran0 ≡ 1.0 ran1 ≈ 1.3 ran2 ≈ 2.0 ran3 ≈ 0.6 ranqd1 ≈ 0.10 ranqd2 ≈ 0.25 ran4 ≈ 4.0 On balance, we recommend ran1 for general use. It is portable, based on Park and Miller’s Minimal Standard generator with an additional shuffle, and has no known (to us) flaws other than period exhaustion. If you are generating more than 100,000,000 random numbers in a single calculation (that is, more than about 5% of ran1’s period), we recommend the use of ran2, with its much longer period. Knuth’s subtractive routine ran3 seems to be the timing winner among portable routines. Unfortunately the subtractive method is not so well studied, and not a standard. We like to keep ran3 in reserve for a “second opinion,” substituting it when we suspect another generator of introducing unwanted correlations into a calculation. The routine ran4 generates extremely good random deviates, and has some other nice properties, but it is slow. See §7.5 for discussion. Finally, the quick and dirty in-line generators ranqd1 and ranqd2 are very fast, but they are somewhat machine dependent, and at best only as good as a 32-bit linear congruential generator ever is — in our view not good enough in many situations. We would use these only in very special cases, where speed is critical. CITED REFERENCES AND FURTHER READING: Park, S.K., and Miller, K.W. 1988, Communications of the ACM, vol. 31, pp. 1192–1201. [1] Schrage, L. 1979, ACM Transactions on Mathematical Software, vol. 5, pp. 132–138. [2] Bratley, P., Fox, B.L., and Schrage, E.L. 1983, A Guide to Simulation (New York: Springer￾Verlag). [3] Knuth, D.E. 1981, Seminumerical Algorithms, 2nd ed., vol. 2 of The Art of Computer Programming (Reading, MA: Addison-Wesley), §§3.2–3.3. [4] Kahaner, D., Moler, C., and Nash, S. 1989, Numerical Methods and Software (Englewood Cliffs, NJ: Prentice Hall), Chapter 10. [5] L’Ecuyer, P. 1988, Communications of the ACM, vol. 31, pp. 742–774. [6] Forsythe, G.E., Malcolm, M.A., and Moler, C.B. 1977, Computer Methods for Mathematical Computations (Englewood Cliffs, NJ: Prentice-Hall), Chapter 10
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有