12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

114 chapter 5TABLE 5.1A Table of a Uniform Pseudorandom Sequence r i Generated by RandNum.java0.04689502438508175 0.20458779675039795 0.5571907470797255 0.056343366735930880.9360668645897467 0.7399399139194867 0.6504153029899553 0.80963337041830570.3251217462543319 0.49447037101884717 0.14307712613141128 0.328581276441882060.5351001685588616 0.9880354395691023 0.9518097953073953 0.368100779256594230.6572443815038911 0.7090768515455671 0.5636787474592884 0.35862773780066490.38336910654033807 0.7400223756022649 0.4162083381184535 0.36580315530380870.7484798900468111 0.522694331447043 0.14865628292663913 0.17418815395271360.41872631012020123 0.9410026890120488 0.1167044926271289 0.87590090127864720.5962535409033703 0.4382385414974941 0.166837081276193 0.275729402460343050.832243048236776 0.45757242791790875 0.7520281492540815 0.88618810317745130.04040867417284555 0.14690149294881334 0.2869627609844023 0.279150544915889530.7854419848382436 0.502978394047627 0.688866810791863 0.085104148559493220.48437643825285326 0.19479360033700366 0.3791230234714642 0.9867371389465821For scientific work we recommend using an industrial-strength random-numbergenerator. To see why, here we assess how bad a careless application of the powerresidue method can be.5.2.3 Assessing Randomness and UniformityBecause the computer’s random numbers are generated according to a definiterule, the numbers in the sequence must be correlated with each other. This canaffect a simulation that assumes random events. Therefore it is wise for you totest a random-number generator to obtain a numerical measure of its uniformityand randomness before you stake your scientific reputation on it. In fact, sometests are simple enough for you to make it a habit to run them simultaneouslywith your simulation. In the examples to follow, we test for either randomness oruniformity.1. Probably the most obvious, but often neglected, test for randomness and uniformityis to look at the numbers generated. For example, Table 5.1 presentssome output from RandNum.java. If you just look at these numbers, you willknow immediately that they all lie between 0 and 1, that they appear to differfrom each other, and that there is no obvious pattern (like 0.3333).2. As we have seen, a quick visual test (Figure 5.2) involves taking this same listand plotting it with r i as ordinate and i as abscissa. Observe how there appearsto be a uniform distribution between 0 and 1 and no particular correlation−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 114

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!