Error in text, section 7.1 (random numbers)


gjm
04-04-2011, 09:59 AM
(This is an erratum report for the text, not the code. It's not at all clear that it belongs here, but nowhere else seems to be more obvious. The email address info@nr.com, recommended in the book itself for submitting errata, appears not to exist any more; at least, mail sent there bounces with a "that recipient does not exist" message. Forum admins, please feel free to move this somewhere more suitable.)

Chapter 7 (Random Numbers), section 7.1 (Uniform Deviates), page 343 (below the definition of Ran) says:

If you need a random integer between 1 and n (inclusive), say, then the expression 1 + myran.int64() % (n-1) is perfectly OK (though there are faster idioms than the use of %).

No, that expression is not perfectly OK! It will produce values from 1 to n-1 inclusive. You want 1 + myran.int64() % n instead.

Saul Teukolsky
04-06-2011, 09:41 AM
Thanks, you're correct. We'll fix this in the next reprinting.

Saul Teukolsky

gjm
04-06-2011, 09:55 AM
You're welcome. Is there any better place than this for reporting errata?

Saul Teukolsky
04-06-2011, 07:36 PM
This is fine. In some cases, especially with code bugs, we'll post a link to a post like this in "Official Bug Reports" as well.

gjm
04-07-2011, 03:40 AM
OK. Then I have another erratum to report: The copyright page says that comments should be sent to info@nr.com, but in fact doing so doesn't work: mail to that address bounces. Either info@nr.com should be resurrected, or the text should be amended to point readers to the forum.

Saul Teukolsky
04-07-2011, 08:05 PM
Yes, we'll fix this also in the next reprinting.

Thanks.