Bug 228662 - rand man page gives out-of-date advice
Summary: rand man page gives out-of-date advice
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: man-pages
Version: 6
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact: Tommy Reynolds
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-02-14 09:15 UTC by Mark Summerfield
Modified: 2007-11-30 22:11 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2007-02-15 09:41:50 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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:1.8.0.9) Gecko/20070131 Fedora/1.5.0.9-2.fc6 Firefox/1.5.0.9 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 +
		     1.0)));

	      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:
Always


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.


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