mirror of https://github.com/mkerrisk/man-pages
Recommend use or random_r(3) for multithreaded appliucations that need
independent, reproducible sequences of random numbers. Move references to "The Art of Computer Programming" and "Numerical Recipes", formerly in rand(3), to this page. Add drand48(93) to SEE ALSO list.
This commit is contained in:
parent
a5ed744769
commit
5b475602ef
|
@ -28,7 +28,7 @@
|
|||
.\" Modified Sat Jul 24 18:13:39 1993 by Rik Faith (faith@cs.unc.edu)
|
||||
.\" Modified Sun Aug 20 21:47:07 2000, aeb
|
||||
.\"
|
||||
.TH RANDOM 3 2007-07-26 "GNU" "Linux Programmer's Manual"
|
||||
.TH RANDOM 3 2008-03-07 "GNU" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
random, srandom, initstate, setstate \- random number generator
|
||||
.SH SYNOPSIS
|
||||
|
@ -54,7 +54,7 @@ Feature Test Macro Requirements for glibc (see
|
|||
.BR srandom (),
|
||||
.BR initstate (),
|
||||
.BR setstate ():
|
||||
_SVID_SOURCE || |_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
|
||||
_SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
|
||||
.ad b
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
|
@ -137,6 +137,27 @@ Current "optimal" values for the size of the state array \fIn\fP are
|
|||
the nearest known amount.
|
||||
Using less than 8 bytes will cause an
|
||||
error.
|
||||
.PP
|
||||
This function should not be used in cases where multiple threads use
|
||||
.BR random ()
|
||||
and the behavior should be reproducible.
|
||||
Use
|
||||
.BR random_r (3)
|
||||
for that purpose.
|
||||
.PP
|
||||
Random-number generation is a complex topic.
|
||||
.I 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, 2007, 3rd ed.)
|
||||
provides an excellent discussion of practical random-number generation
|
||||
issues in Chapter 7 (Random Numbers).
|
||||
.PP
|
||||
For a more theoretical discussion which also covers many practical issues
|
||||
in depth, see Chapter 3 (Random Numbers) in Donald E. Knuth's
|
||||
.IR "The Art of Computer Programming" ,
|
||||
volume 2 (Seminumerical Algorithms), 2nd ed.; Reading, Massachusetts:
|
||||
Addison-Wesley Publishing Company, 1981.
|
||||
.SH "SEE ALSO"
|
||||
.BR drand48 (3),
|
||||
.BR rand (3),
|
||||
.BR srand (3)
|
||||
|
|
Loading…
Reference in New Issue