Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-whrandom.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-bisect.html" />
<link rel="prev" href="module-random.html" />
<link rel="parent" href="misc.html" />
<link rel="next" href="module-bisect.html" />
<meta name='aesop' content='information' />
<title>5.10 whrandom -- Pseudo-random number generator</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.9 random "
href="module-random.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
href="misc.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.11 bisect "
href="module-bisect.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-random.html">5.9 random </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-bisect.html">5.11 bisect </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0071000000000000000000">
5.10 <tt class="module">whrandom</tt> --
Pseudo-random number generator</A>
</H1>
<P>
<A NAME="module-whrandom"></A>
<P>
<div class="versionnote"><b>Deprecated since release 2.1.</b>
Use <tt class="module"><a href="module-random.html">random</a></tt> instead.</div><p></p>
<P>
<span class="note"><b class="label">Note:</b>
This module was an implementation detail of the
<tt class="module"><a href="module-random.html">random</a></tt> module in releases of Python prior to 2.1. It is
no longer used. Please do not use this module directly; use
<tt class="module"><a href="module-random.html">random</a></tt> instead.</span>
<P>
This module implements a Wichmann-Hill pseudo-random number generator
class that is also named <tt class="class">whrandom</tt>. Instances of the
<tt class="class">whrandom</tt> class conform to the Random Number Generator
interface described in the docs for the <tt class="module"><a href="module-random.html">random</a></tt> module.
They also offer the
following method, specific to the Wichmann-Hill algorithm:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1323' xml:id='l2h-1323' class="method">seed</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>x, y, z</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Initializes the random number generator from the integers <var>x</var>,
<var>y</var> and <var>z</var>. When the module is first imported, the random
number is initialized using values derived from the current time.
If <var>x</var>, <var>y</var>, and <var>z</var> are either omitted or <code>0</code>, the
seed will be computed from the current system time. If one or two
of the parameters are <code>0</code>, but not all three, the zero values
are replaced by ones. This causes some apparently different seeds
to be equal, with the corresponding result on the pseudo-random
series produced by the generator.
</dl>
<P>
Other supported methods include:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1324' xml:id='l2h-1324' class="function">choice</tt></b>(</nobr></td>
<td><var>seq</var>)</td></tr></table></dt>
<dd>
Chooses a random element from the non-empty sequence <var>seq</var> and returns it.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1325' xml:id='l2h-1325' class="function">randint</tt></b>(</nobr></td>
<td><var>a, b</var>)</td></tr></table></dt>
<dd>
Returns a random integer <var>N</var> such that <code><var>a</var>&lt;=<var>N</var>&lt;=<var>b</var></code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1326' xml:id='l2h-1326' class="function">random</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the next random floating point number in the range [0.0 ... 1.0).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1327' xml:id='l2h-1327' class="function">seed</tt></b>(</nobr></td>
<td><var>x, y, z</var>)</td></tr></table></dt>
<dd>
Initializes the random number generator from the integers <var>x</var>,
<var>y</var> and <var>z</var>. When the module is first imported, the random
number is initialized using values derived from the current time.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1328' xml:id='l2h-1328' class="function">uniform</tt></b>(</nobr></td>
<td><var>a, b</var>)</td></tr></table></dt>
<dd>
Returns a random real number <var>N</var> such that <code><var>a</var>&lt;=<var>N</var>&lt;<var>b</var></code>.
</dl>
<P>
When imported, the <tt class="module">whrandom</tt> module also creates an instance of
the <tt class="class">whrandom</tt> class, and makes the methods of that instance
available at the module level. Therefore one can write either
<code>N = whrandom.random()</code> or:
<P>
<div class="verbatim"><pre>
generator = whrandom.whrandom()
N = generator.random()
</pre></div>
<P>
Note that using separate instances of the generator leads to
independent sequences of pseudo-random numbers.
<P>
<div class="seealso">
<p class="heading">See Also:</p>
<dl compact="compact" class="seemodule">
<dt>Module <b><tt class="module"><a href="module-random.html">random</a></tt>:</b>
<dd>Generators for various random distributions and
documentation for the Random Number Generator
interface.
</dl>
<div class="seetext"><p>Wichmann, B. A. &amp; Hill, I. D., ``Algorithm AS 183:
An efficient and portable pseudo-random number generator'',
<em class="citetitle"
>Applied Statistics</em> 31 (1982) 188-190.</p></div>
</div>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.9 random "
href="module-random.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
href="misc.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.11 bisect "
href="module-bisect.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-random.html">5.9 random </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-bisect.html">5.11 bisect </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>