Bug 228662 - rand man page gives out-of-date advice
rand man page gives out-of-date advice
Product: Fedora
Classification: Fedora
Component: man-pages (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ivana Varekova
Tommy Reynolds
Depends On:
  Show dependency treegraph
Reported: 2007-02-14 04:15 EST by Mark Summerfield
Modified: 2007-11-30 17:11 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-02-15 04:41:50 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Mark Summerfield 2007-02-14 04:15:09 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20070131 Fedora/ Firefox/ pango-text

Description of problem:
The rand man page NOTES section says this:

"In Numerical Recipes in C: The Art of  Scientific  Computing
       (William	 H.  Press,  Brian  P. Flannery, Saul A. Teukolsky,
       William T. Vetterling; New York: Cambridge University Press,
       1992 (2nd ed., p. 277)), the following comments are made:
	      "If  you	want to generate a random integer between 1
	      and 10, you should always do it by  using	 high-order
	      bits, as in

		     j	=  1  + (int) (10.0 * (rand() / (RAND_MAX +

	      and never by anything resembling

		     j = 1 + (rand() % 10);

	      (which uses lower-order bits)."

What they wrote was applicable in 
the 80s, back when the pseudo-random number generators they used were so 
bad that the lowestmost bit was alternating 0 1 0 1 0 1 and the 
next-to-lowermost bit was part of a cycle like 0 0 1 1 0 0 1 1, etc. 
Needless to say, such a pseudo-random number generator doesn't pass some 
rather fundamental statistical test (cf. Seminumerical Algorithms by 
Knuth), and I'd tend to put the blame on the generator, not on the 
program that uses it. 

The Linux rand() function does not have this problem, so can't this section be cut out of the man page, or failing that how about adding a note:

"Most modern rand() functions, including the one provided on Linux systems,
do not suffer from this problem, so using expressions like rand() % 10 works fine."

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.man rand

Actual Results:

Expected Results:

Additional info:
Comment 1 Karsten Wade 2007-02-14 04:43:28 EST
The rand manual page is part of the man-pages package.  I'm reassigning this bug
to that package.  Regardless, I suspect the content is actually from upstream,
so fixing it may not be directly in the hands of anyone from Fedora.
Comment 2 Ivana Varekova 2007-02-15 04:41:50 EST
Thanks. Fixed in man-pages-2.43-7.fc7.

Note You need to log in before you can comment on or make changes to this bug.