mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	 e47da0ae04
			
		
	
	
		e47da0ae04
		
	
	
	
	
		
			
			* \bcode, \ecode added everywhere
	* \label{module-foo} added everywhere
	* A few \seealso sections added.
	* Indentation fixed inside verbatim in lib*tex files
		
	
			
		
			
				
	
	
		
			50 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
| \section{Standard Module \sectcode{whrandom}}
 | |
| \label{module-whrandom}
 | |
| \stmodindex{whrandom}
 | |
| 
 | |
| This module implements a Wichmann-Hill pseudo-random number generator
 | |
| class that is also named \code{whrandom}.  Instances of the
 | |
| \code{whrandom} class have the following methods:
 | |
| \renewcommand{\indexsubitem}{(in module whrandom)}
 | |
| 
 | |
| \begin{funcdesc}{choice}{seq}
 | |
| Chooses a random element from the non-empty sequence \var{seq} and returns it.
 | |
| \end{funcdesc}
 | |
| 
 | |
| \begin{funcdesc}{randint}{a\, b}
 | |
| Returns a random integer \var{N} such that \code{\var{a}<=\var{N}<=\var{b}}.
 | |
| \end{funcdesc}
 | |
| 
 | |
| \begin{funcdesc}{random}{}
 | |
| Returns the next random floating point number in the range [0.0 ... 1.0).
 | |
| \end{funcdesc}
 | |
| 
 | |
| \begin{funcdesc}{seed}{x\, y\, z}
 | |
| Initializes the random number generator from the integers
 | |
| \var{x},
 | |
| \var{y}
 | |
| and
 | |
| \var{z}.
 | |
| When the module is first imported, the random number is initialized
 | |
| using values derived from the current time.
 | |
| \end{funcdesc}
 | |
| 
 | |
| \begin{funcdesc}{uniform}{a\, b}
 | |
| Returns a random real number \var{N} such that \code{\var{a}<=\var{N}<\var{b}}.
 | |
| \end{funcdesc}
 | |
| 
 | |
| When imported, the \code{whrandom} module also creates an instance of
 | |
| the \code{whrandom} class, and makes the methods of that instance
 | |
| available at the module level.  Therefore one can write either 
 | |
| \code{N = whrandom.random()} or:
 | |
| \bcode\begin{verbatim}
 | |
| generator = whrandom.whrandom()
 | |
| N = generator.random()
 | |
| \end{verbatim}\ecode
 | |
| %
 | |
| \begin{seealso}
 | |
| \seemodule{random}{generators for various random distributions}
 | |
| \seetext{Wichmann, B. A. \& Hill, I. D., ``Algorithm AS 183: 
 | |
| An efficient and portable pseudo-random number generator'', 
 | |
| Applied Statistics 31 (1982) 188-190}
 | |
| \end{seealso}
 |