| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>pypdevsbbl.extra.rngstreams package — Python(P)DEVS-BBL documentation</title>
- <link rel="stylesheet" href="_static/nature.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <link rel="stylesheet" type="text/css" href="_static/custom.css" />
- <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <script type="text/javascript" src="_static/language_data.js"></script>
- <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.html" />
- <link rel="next" title="pypdevsbbl.extra.rngstreams.distributions module" href="pypdevsbbl.extra.rngstreams.distributions.html" />
- <link rel="prev" title="pypdevsbbl.extra package" href="pypdevsbbl.extra.html" />
- </head><body>
- <div class="related" role="navigation" aria-label="related navigation">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="genindex.html" title="General Index"
- accesskey="I">index</a></li>
- <li class="right" >
- <a href="py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.extra.rngstreams.distributions.html" title="pypdevsbbl.extra.rngstreams.distributions module"
- accesskey="N">next</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.extra.html" title="pypdevsbbl.extra package"
- accesskey="P">previous</a> |</li>
- <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> »</li>
- <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> »</li>
- <li class="nav-item nav-item-2"><a href="pypdevsbbl.extra.html" accesskey="U">pypdevsbbl.extra package</a> »</li>
- </ul>
- </div>
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <div class="section" id="module-pypdevsbbl.extra.rngstreams">
- <span id="pypdevsbbl-extra-rngstreams-package"></span><h1>pypdevsbbl.extra.rngstreams package<a class="headerlink" href="#module-pypdevsbbl.extra.rngstreams" title="Permalink to this headline">¶</a></h1>
- <p>Subpackage for RNGs.</p>
- <dl class="docutils">
- <dt>This file contains:</dt>
- <dd><ul class="first last simple">
- <li>A Python wrapper for
- <a class="reference external" href="http://statmath.wu.ac.at/software/RngStreams/">P. L’Ecuyers’ and Richard Simard’s RngStreams</a>.
- This code was based on <a class="reference external" href="https://github.com/adamzjw/RngStream-in-Python/blob/master/RngStream.py">https://github.com/adamzjw/RngStream-in-Python/blob/master/RngStream.py</a> .</li>
- <li>Some helper classes for working with RNGs.</li>
- </ul>
- </dd>
- </dl>
- <p>By default, the MRG32k3a-based RngStreams are used for generating random
- numbers in the building blocks, but this can be changed to Python’s builtin
- <code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code> module, or the <code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.random</span></code> module, as is required by
- the user. Call <a class="reference internal" href="#pypdevsbbl.extra.rngstreams.setGeneratorType" title="pypdevsbbl.extra.rngstreams.setGeneratorType"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setGeneratorType()</span></code></a> to do so.</p>
- <div class="admonition warning">
- <p class="first admonition-title">Warning</p>
- <p>In order to use RngStreams, please make sure you have the required
- library installed. This consists of the compiled C code for RngStreams
- and should be located in the <code class="file docutils literal notranslate"><span class="pre">src/dependencies/RngStreams/c</span></code> folder.</p>
- <p class="last">Whenever this library cannot be found, a warning will be printed and the
- builtin <code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code> module will be used instead.</p>
- </div>
- <dl class="class">
- <dt id="pypdevsbbl.extra.rngstreams.Generators">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">Generators</code><a class="reference internal" href="_modules/pypdevsbbl/extra/rngstreams.html#Generators"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.Generators" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">enum.Enum</span></code></p>
- <p>Enum helper class to determine the RNG to use.</p>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.Generators.RANDOM">
- <code class="descname">RANDOM</code><em class="property"> = 0</em><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.Generators.RANDOM" title="Permalink to this definition">¶</a></dt>
- <dd><p>Use Python’s builtin RNG. (i.e. the <code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code> module)</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.Generators.NUMPY">
- <code class="descname">NUMPY</code><em class="property"> = 1</em><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.Generators.NUMPY" title="Permalink to this definition">¶</a></dt>
- <dd><p>Use Numpy’s RNG.</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.Generators.RNGSTREAMS">
- <code class="descname">RNGSTREAMS</code><em class="property"> = 2</em><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.Generators.RNGSTREAMS" title="Permalink to this definition">¶</a></dt>
- <dd><p>Use Pierre L’Ecuyers’ and Richard Simard’s RngStreams.</p>
- <div class="admonition seealso">
- <p class="first admonition-title">See also</p>
- <p class="last"><a class="reference external" href="http://statmath.wu.ac.at/software/RngStreams/">http://statmath.wu.ac.at/software/RngStreams/</a></p>
- </div>
- </dd></dl>
- </dd></dl>
- <dl class="data">
- <dt id="pypdevsbbl.extra.rngstreams.GENERATE_WITH">
- <code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">GENERATE_WITH</code><em class="property"> = <Generators.RANDOM: 0></em><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.GENERATE_WITH" title="Permalink to this definition">¶</a></dt>
- <dd><p>Identifies the stream to use.</p>
- <p>Set this value to the desired RNG stream, before the model is constructed.
- Must be a value from the <a class="reference internal" href="#pypdevsbbl.extra.rngstreams.Generators" title="pypdevsbbl.extra.rngstreams.Generators"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generators</span></code></a> enum.</p>
- </dd></dl>
- <dl class="function">
- <dt id="pypdevsbbl.extra.rngstreams.setGeneratorType">
- <code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">setGeneratorType</code><span class="sig-paren">(</span><em>gen_type</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/extra/rngstreams.html#setGeneratorType"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.setGeneratorType" title="Permalink to this definition">¶</a></dt>
- <dd><p>Sets the <a class="reference internal" href="#pypdevsbbl.extra.rngstreams.GENERATE_WITH" title="pypdevsbbl.extra.rngstreams.GENERATE_WITH"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GENERATE_WITH</span></code></a> variable.</p>
- <p>Call this function to validly set the generator type.</p>
- <div class="admonition seealso">
- <p class="first admonition-title">See also</p>
- <ul class="last simple">
- <li><a class="reference internal" href="#pypdevsbbl.extra.rngstreams.GENERATE_WITH" title="pypdevsbbl.extra.rngstreams.GENERATE_WITH"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GENERATE_WITH</span></code></a></li>
- <li><a class="reference internal" href="#pypdevsbbl.extra.rngstreams.Generators" title="pypdevsbbl.extra.rngstreams.Generators"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generators</span></code></a></li>
- </ul>
- </div>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">May be changed during construction of RNG-dependent building blocks.
- This allows the combination of multiple generator types.</p>
- </div>
- </dd></dl>
- <dl class="class">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState">
- <em class="property">class </em><code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">RngStream_InfoState</code><a class="reference internal" href="_modules/pypdevsbbl/extra/rngstreams.html#RngStream_InfoState"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState" title="Permalink to this definition">¶</a></dt>
- <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">_ctypes.Structure</span></code></p>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Anti">
- <code class="descname">Anti</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Anti" title="Permalink to this definition">¶</a></dt>
- <dd><p>Structure/Union member</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Bg">
- <code class="descname">Bg</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Bg" title="Permalink to this definition">¶</a></dt>
- <dd><p>Structure/Union member</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Cg">
- <code class="descname">Cg</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Cg" title="Permalink to this definition">¶</a></dt>
- <dd><p>Structure/Union member</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Ig">
- <code class="descname">Ig</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Ig" title="Permalink to this definition">¶</a></dt>
- <dd><p>Structure/Union member</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.IncPrec">
- <code class="descname">IncPrec</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.IncPrec" title="Permalink to this definition">¶</a></dt>
- <dd><p>Structure/Union member</p>
- </dd></dl>
- <dl class="attribute">
- <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.name">
- <code class="descname">name</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.name" title="Permalink to this definition">¶</a></dt>
- <dd><p>Structure/Union member</p>
- </dd></dl>
- </dd></dl>
- <dl class="function">
- <dt id="pypdevsbbl.extra.rngstreams.setSeed">
- <code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">setSeed</code><span class="sig-paren">(</span><em>gen</em>, <em>seed</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/extra/rngstreams.html#setSeed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.setSeed" title="Permalink to this definition">¶</a></dt>
- <dd><p>Sets a new seed for the RngStreams generator object.</p>
- <p>RngStream requires a seed that is of size 6. This function makes it
- easier in a sense that when it does not find enough values for its seed,
- it will automatically fill the seed until it is large enough.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>gen</strong> (<em>object</em>) – The generator object (RngStreams).</li>
- <li><strong>seed</strong> – Either a numeric, or an iterable.
- The new seed to use.</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">-1 on faillure, 0 on success.</p>
- </td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><p class="first last"><strong>ValueError</strong> – When an invalid seed was given.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="function">
- <dt id="pypdevsbbl.extra.rngstreams.createStream">
- <code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">createStream</code><span class="sig-paren">(</span><em>name</em>, <em>seed=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/extra/rngstreams.html#createStream"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.createStream" title="Permalink to this definition">¶</a></dt>
- <dd><p>Creates a custom RNG stream, w.r.t. the requested generator.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>name</strong> (<em>str</em>) – The unique name in case of an RngStreams generator.</li>
- <li><strong>seed</strong> – Either a numeric, or an iterable. The seed to use.
- When <code class="docutils literal notranslate"><span class="pre">None</span></code>, no seed will be set. Defaults to
- <code class="docutils literal notranslate"><span class="pre">None</span></code>.</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <dl class="function">
- <dt id="pypdevsbbl.extra.rngstreams.U01">
- <code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">U01</code><span class="sig-paren">(</span><em>gen</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/extra/rngstreams.html#U01"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.U01" title="Permalink to this definition">¶</a></dt>
- <dd><p>Return a uniformly distributed random variable within (0, 1).</p>
- <p>This function works no matter the selected generator.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>gen</strong> (<em>object</em>) – The generator to use.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A numpy.float64 in the range (0, 1).</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
- <div class="section" id="submodules">
- <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
- <div class="toctree-wrapper compound">
- <ul>
- <li class="toctree-l1"><a class="reference internal" href="pypdevsbbl.extra.rngstreams.distributions.html">pypdevsbbl.extra.rngstreams.distributions module</a></li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
- <div class="sphinxsidebarwrapper">
- <h4>Previous topic</h4>
- <p class="topless"><a href="pypdevsbbl.extra.html"
- title="previous chapter">pypdevsbbl.extra package</a></p>
- <h4>Next topic</h4>
- <p class="topless"><a href="pypdevsbbl.extra.rngstreams.distributions.html"
- title="next chapter">pypdevsbbl.extra.rngstreams.distributions module</a></p>
- <div id="searchbox" style="display: none" role="search">
- <h3>Quick search</h3>
- <div class="searchformwrapper">
- <form class="search" action="search.html" method="get">
- <input type="text" name="q" />
- <input type="submit" value="Go" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- <div class="related" role="navigation" aria-label="related navigation">
- <h3>Navigation</h3>
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="genindex.html" title="General Index"
- >index</a></li>
- <li class="right" >
- <a href="py-modindex.html" title="Python Module Index"
- >modules</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.extra.rngstreams.distributions.html" title="pypdevsbbl.extra.rngstreams.distributions module"
- >next</a> |</li>
- <li class="right" >
- <a href="pypdevsbbl.extra.html" title="pypdevsbbl.extra package"
- >previous</a> |</li>
- <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> »</li>
- <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> »</li>
- <li class="nav-item nav-item-2"><a href="pypdevsbbl.extra.html" >pypdevsbbl.extra package</a> »</li>
- </ul>
- </div>
- <div class="footer" role="contentinfo">
- © Copyright 2020, Randy Paredis.
- Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
- </div>
- </body>
- </html>
|