Bug 228662

Summary: rand man page gives out-of-date advice
Product: [Fedora] Fedora Reporter: Mark Summerfield <mark>
Component: man-pagesAssignee: Ivana Varekova <varekova>
Status: CLOSED RAWHIDE QA Contact: Tommy Reynolds <tommy.reynolds>
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: mjohnson, stickster
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-02-15 09:41:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Mark Summerfield 2007-02-14 09:15:09 UTC
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 09:43:28 UTC
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 09:41:50 UTC
Thanks. Fixed in man-pages-2.43-7.fc7.