c7-0 (779514)
Текст из файла
Random Numbers7.0 IntroductionIt may seem perverse to use a computer, that most precise and deterministic ofall machines conceived by the human mind, to produce “random” numbers. Morethan perverse, it may seem to be a conceptual impossibility. Any program, after all,will produce output that is entirely predictable, hence not truly “random.”Nevertheless, practical computer “random number generators” are in commonuse.
We will leave it to philosophers of the computer age to resolve the paradox ina deep way (see, e.g., Knuth [1] §3.5 for discussion and references). One sometimeshears computer-generated sequences termed pseudo-random, while the word randomis reserved for the output of an intrinsically random physical process, like the elapsedtime between clicks of a Geiger counter placed next to a sample of some radioactiveelement.
We will not try to make such fine distinctions.A working, though imprecise, definition of randomness in the context ofcomputer-generated sequences, is to say that the deterministic program that producesa random sequence should be different from, and — in all measurable respects —statistically uncorrelated with, the computer program that uses its output. In otherwords, any two different random number generators ought to produce statisticallythe same results when coupled to your particular applications program.
If they don’t,then at least one of them is not (from your point of view) a good generator.The above definition may seem circular, comparing, as it does, one generator toanother. However, there exists a body of random number generators which mutuallydo satisfy the definition over a very, very broad class of applications programs.And it is also found empirically that statistically identical results are obtained fromrandom numbers produced by physical processes. So, because such generators areknown to exist, we can leave to the philosophers the problem of defining them.A pragmatic point of view, then, is that randomness is in the eye of the beholder(or programmer). What is random enough for one application may not be randomenough for another.
Still, one is not entirely adrift in a sea of incommensurableapplications programs: There is a certain list of statistical tests, some sensible andsome merely enshrined by history, which on the whole will do a very good jobof ferreting out any correlations that are likely to be detected by an applicationsprogram (in this case, yours). Good random number generators ought to pass all ofthese tests; or at least the user had better be aware of any that they fail, so that he orshe will be able to judge whether they are relevant to the case at hand.274Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).Chapter 7.7.1 Uniform Deviates275As for references on this subject, the one to turn to first is Knuth [1]. Thentry [2].
Only a few of the standard books on numerical methods [3-4] treat topicsrelating to random numbers.Bratley, P., Fox, B.L., and Schrage, E.L. 1983, A Guide to Simulation (New York: SpringerVerlag). [2]Dahlquist, G., and Bjorck, A. 1974, Numerical Methods (Englewood Cliffs, NJ: Prentice-Hall),Chapter 11. [3]Forsythe, G.E., Malcolm, M.A., and Moler, C.B.
1977, Computer Methods for MathematicalComputations (Englewood Cliffs, NJ: Prentice-Hall), Chapter 10. [4]7.1 Uniform DeviatesUniform deviates are just random numbers that lie within a specified range(typically 0 to 1), with any one number in the range just as likely as any other.
Theyare, in other words, what you probably think “random numbers” are. However,we want to distinguish uniform deviates from other sorts of random numbers, forexample numbers drawn from a normal (Gaussian) distribution of specified meanand standard deviation. These other sorts of deviates are almost always generated byperforming appropriate operations on one or more uniform deviates, as we will seein subsequent sections.
So, a reliable source of random uniform deviates, the subjectof this section, is an essential building block for any sort of stochastic modelingor Monte Carlo computer work.System-Supplied Random Number GeneratorsMost C implementations have, lurking within, a pair of library routines forinitializing, and then generating, “random numbers.” In ANSI C, the synopsis is:#include <stdlib.h>#define RAND_MAX ...void srand(unsigned seed);int rand(void);You initialize the random number generator by invoking srand(seed) withsome arbitrary seed.
Each initializing value will typically result in a differentrandom sequence, or a least a different starting point in some one enormously longsequence. The same initializing value of seed will always return the same randomsequence, however.You obtain successive random numbers in the sequence by successive calls torand().
That function returns an integer that is typically in the range 0 to thelargest representable positive value of type int (inclusive). Usually, as in ANSI C,this largest value is available as RAND_MAX, but sometimes you have to figure it outfor yourself. If you want a random float value between 0.0 (inclusive) and 1.0(exclusive), you get it by an expression likeSample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).CITED REFERENCES AND FURTHER READING:Knuth, D.E. 1981, Seminumerical Algorithms, 2nd ed., vol.
2 of The Art of Computer Programming(Reading, MA: Addison-Wesley), Chapter 3, especially §3.5. [1].
Характеристики
Тип файла PDF
PDF-формат наиболее широко используется для просмотра любого типа файлов на любом устройстве. В него можно сохранить документ, таблицы, презентацию, текст, чертежи, вычисления, графики и всё остальное, что можно показать на экране любого устройства. Именно его лучше всего использовать для печати.
Например, если Вам нужно распечатать чертёж из автокада, Вы сохраните чертёж на флешку, но будет ли автокад в пункте печати? А если будет, то нужная версия с нужными библиотеками? Именно для этого и нужен формат PDF - в нём точно будет показано верно вне зависимости от того, в какой программе создали PDF-файл и есть ли нужная программа для его просмотра.















