Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / html / python / lib / module-whrandom.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-bisect.html" />
13<link rel="prev" href="module-random.html" />
14<link rel="parent" href="misc.html" />
15<link rel="next" href="module-bisect.html" />
16<meta name='aesop' content='information' />
17<title>5.10 whrandom -- Pseudo-random number generator</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="5.9 random "
25 href="module-random.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
28 href="misc.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="5.11 bisect "
31 href="module-bisect.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-random.html">5.9 random </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-bisect.html">5.11 bisect </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0071000000000000000000">
565.10 <tt class="module">whrandom</tt> --
57 Pseudo-random number generator</A>
58</H1>
59
60<P>
61<A NAME="module-whrandom"></A>
62
63<P>
64<div class="versionnote"><b>Deprecated since release 2.1.</b>
65Use <tt class="module"><a href="module-random.html">random</a></tt> instead.</div><p></p>
66
67<P>
68<span class="note"><b class="label">Note:</b>
69This module was an implementation detail of the
70<tt class="module"><a href="module-random.html">random</a></tt> module in releases of Python prior to 2.1. It is
71no longer used. Please do not use this module directly; use
72<tt class="module"><a href="module-random.html">random</a></tt> instead.</span>
73
74<P>
75This module implements a Wichmann-Hill pseudo-random number generator
76class that is also named <tt class="class">whrandom</tt>. Instances of the
77<tt class="class">whrandom</tt> class conform to the Random Number Generator
78interface described in the docs for the <tt class="module"><a href="module-random.html">random</a></tt> module.
79They also offer the
80following method, specific to the Wichmann-Hill algorithm:
81
82<P>
83<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
84 <td><nobr><b><tt id='l2h-1323' xml:id='l2h-1323' class="method">seed</tt></b>(</nobr></td>
85 <td><var></var><big>[</big><var>x, y, z</var><big>]</big><var></var>)</td></tr></table></dt>
86<dd>
87 Initializes the random number generator from the integers <var>x</var>,
88 <var>y</var> and <var>z</var>. When the module is first imported, the random
89 number is initialized using values derived from the current time.
90 If <var>x</var>, <var>y</var>, and <var>z</var> are either omitted or <code>0</code>, the
91 seed will be computed from the current system time. If one or two
92 of the parameters are <code>0</code>, but not all three, the zero values
93 are replaced by ones. This causes some apparently different seeds
94 to be equal, with the corresponding result on the pseudo-random
95 series produced by the generator.
96</dl>
97
98<P>
99Other supported methods include:
100
101<P>
102<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
103 <td><nobr><b><tt id='l2h-1324' xml:id='l2h-1324' class="function">choice</tt></b>(</nobr></td>
104 <td><var>seq</var>)</td></tr></table></dt>
105<dd>
106Chooses a random element from the non-empty sequence <var>seq</var> and returns it.
107</dl>
108
109<P>
110<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
111 <td><nobr><b><tt id='l2h-1325' xml:id='l2h-1325' class="function">randint</tt></b>(</nobr></td>
112 <td><var>a, b</var>)</td></tr></table></dt>
113<dd>
114Returns a random integer <var>N</var> such that <code><var>a</var>&lt;=<var>N</var>&lt;=<var>b</var></code>.
115</dl>
116
117<P>
118<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
119 <td><nobr><b><tt id='l2h-1326' xml:id='l2h-1326' class="function">random</tt></b>(</nobr></td>
120 <td><var></var>)</td></tr></table></dt>
121<dd>
122Returns the next random floating point number in the range [0.0 ... 1.0).
123</dl>
124
125<P>
126<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
127 <td><nobr><b><tt id='l2h-1327' xml:id='l2h-1327' class="function">seed</tt></b>(</nobr></td>
128 <td><var>x, y, z</var>)</td></tr></table></dt>
129<dd>
130Initializes the random number generator from the integers <var>x</var>,
131<var>y</var> and <var>z</var>. When the module is first imported, the random
132number is initialized using values derived from the current time.
133</dl>
134
135<P>
136<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
137 <td><nobr><b><tt id='l2h-1328' xml:id='l2h-1328' class="function">uniform</tt></b>(</nobr></td>
138 <td><var>a, b</var>)</td></tr></table></dt>
139<dd>
140Returns a random real number <var>N</var> such that <code><var>a</var>&lt;=<var>N</var>&lt;<var>b</var></code>.
141</dl>
142
143<P>
144When imported, the <tt class="module">whrandom</tt> module also creates an instance of
145the <tt class="class">whrandom</tt> class, and makes the methods of that instance
146available at the module level. Therefore one can write either
147<code>N = whrandom.random()</code> or:
148
149<P>
150<div class="verbatim"><pre>
151generator = whrandom.whrandom()
152N = generator.random()
153</pre></div>
154
155<P>
156Note that using separate instances of the generator leads to
157independent sequences of pseudo-random numbers.
158
159<P>
160<div class="seealso">
161 <p class="heading">See Also:</p>
162
163 <dl compact="compact" class="seemodule">
164 <dt>Module <b><tt class="module"><a href="module-random.html">random</a></tt>:</b>
165 <dd>Generators for various random distributions and
166 documentation for the Random Number Generator
167 interface.
168 </dl>
169 <div class="seetext"><p>Wichmann, B. A. &amp; Hill, I. D., ``Algorithm AS 183:
170 An efficient and portable pseudo-random number generator'',
171 <em class="citetitle"
172 >Applied Statistics</em> 31 (1982) 188-190.</p></div>
173</div>
174
175<DIV CLASS="navigation">
176<div class='online-navigation'>
177<p></p><hr />
178<table align="center" width="100%" cellpadding="0" cellspacing="2">
179<tr>
180<td class='online-navigation'><a rel="prev" title="5.9 random "
181 href="module-random.html"><img src='../icons/previous.png'
182 border='0' height='32' alt='Previous Page' width='32' /></A></td>
183<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
184 href="misc.html"><img src='../icons/up.png'
185 border='0' height='32' alt='Up One Level' width='32' /></A></td>
186<td class='online-navigation'><a rel="next" title="5.11 bisect "
187 href="module-bisect.html"><img src='../icons/next.png'
188 border='0' height='32' alt='Next Page' width='32' /></A></td>
189<td align="center" width="100%">Python Library Reference</td>
190<td class='online-navigation'><a rel="contents" title="Table of Contents"
191 href="contents.html"><img src='../icons/contents.png'
192 border='0' height='32' alt='Contents' width='32' /></A></td>
193<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
194 border='0' height='32' alt='Module Index' width='32' /></a></td>
195<td class='online-navigation'><a rel="index" title="Index"
196 href="genindex.html"><img src='../icons/index.png'
197 border='0' height='32' alt='Index' width='32' /></A></td>
198</tr></table>
199<div class='online-navigation'>
200<b class="navlabel">Previous:</b>
201<a class="sectref" rel="prev" href="module-random.html">5.9 random </A>
202<b class="navlabel">Up:</b>
203<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
204<b class="navlabel">Next:</b>
205<a class="sectref" rel="next" href="module-bisect.html">5.11 bisect </A>
206</div>
207</div>
208<hr />
209<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
210</DIV>
211<!--End of Navigation Panel-->
212<ADDRESS>
213See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
214</ADDRESS>
215</BODY>
216</HTML>