pypdevsbbl.extra.rngstreams.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>pypdevsbbl.extra.rngstreams package &#8212; Python(P)DEVS-BBL documentation</title>
  8. <link rel="stylesheet" href="_static/nature.css" type="text/css" />
  9. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  10. <link rel="stylesheet" type="text/css" href="_static/custom.css" />
  11. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  12. <script type="text/javascript" src="_static/jquery.js"></script>
  13. <script type="text/javascript" src="_static/underscore.js"></script>
  14. <script type="text/javascript" src="_static/doctools.js"></script>
  15. <script type="text/javascript" src="_static/language_data.js"></script>
  16. <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>
  17. <link rel="index" title="Index" href="genindex.html" />
  18. <link rel="search" title="Search" href="search.html" />
  19. <link rel="next" title="pypdevsbbl.extra.rngstreams.distributions module" href="pypdevsbbl.extra.rngstreams.distributions.html" />
  20. <link rel="prev" title="pypdevsbbl.extra package" href="pypdevsbbl.extra.html" />
  21. </head><body>
  22. <div class="related" role="navigation" aria-label="related navigation">
  23. <h3>Navigation</h3>
  24. <ul>
  25. <li class="right" style="margin-right: 10px">
  26. <a href="genindex.html" title="General Index"
  27. accesskey="I">index</a></li>
  28. <li class="right" >
  29. <a href="py-modindex.html" title="Python Module Index"
  30. >modules</a> |</li>
  31. <li class="right" >
  32. <a href="pypdevsbbl.extra.rngstreams.distributions.html" title="pypdevsbbl.extra.rngstreams.distributions module"
  33. accesskey="N">next</a> |</li>
  34. <li class="right" >
  35. <a href="pypdevsbbl.extra.html" title="pypdevsbbl.extra package"
  36. accesskey="P">previous</a> |</li>
  37. <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> &#187;</li>
  38. <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> &#187;</li>
  39. <li class="nav-item nav-item-2"><a href="pypdevsbbl.extra.html" accesskey="U">pypdevsbbl.extra package</a> &#187;</li>
  40. </ul>
  41. </div>
  42. <div class="document">
  43. <div class="documentwrapper">
  44. <div class="bodywrapper">
  45. <div class="body" role="main">
  46. <div class="section" id="module-pypdevsbbl.extra.rngstreams">
  47. <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>
  48. <p>Subpackage for RNGs.</p>
  49. <dl class="docutils">
  50. <dt>This file contains:</dt>
  51. <dd><ul class="first last simple">
  52. <li>A Python wrapper for
  53. <a class="reference external" href="http://statmath.wu.ac.at/software/RngStreams/">P. L’Ecuyers’ and Richard Simard’s RngStreams</a>.
  54. 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>
  55. <li>Some helper classes for working with RNGs.</li>
  56. </ul>
  57. </dd>
  58. </dl>
  59. <p>By default, the MRG32k3a-based RngStreams are used for generating random
  60. numbers in the building blocks, but this can be changed to Python’s builtin
  61. <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
  62. 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>
  63. <div class="admonition warning">
  64. <p class="first admonition-title">Warning</p>
  65. <p>In order to use RngStreams, please make sure you have the required
  66. library installed. This consists of the compiled C code for RngStreams
  67. and should be located in the <code class="file docutils literal notranslate"><span class="pre">src/dependencies/RngStreams/c</span></code> folder.</p>
  68. <p class="last">Whenever this library cannot be found, a warning will be printed and the
  69. builtin <code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code> module will be used instead.</p>
  70. </div>
  71. <dl class="class">
  72. <dt id="pypdevsbbl.extra.rngstreams.Generators">
  73. <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>
  74. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">enum.Enum</span></code></p>
  75. <p>Enum helper class to determine the RNG to use.</p>
  76. <dl class="attribute">
  77. <dt id="pypdevsbbl.extra.rngstreams.Generators.RANDOM">
  78. <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>
  79. <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>
  80. </dd></dl>
  81. <dl class="attribute">
  82. <dt id="pypdevsbbl.extra.rngstreams.Generators.NUMPY">
  83. <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>
  84. <dd><p>Use Numpy’s RNG.</p>
  85. </dd></dl>
  86. <dl class="attribute">
  87. <dt id="pypdevsbbl.extra.rngstreams.Generators.RNGSTREAMS">
  88. <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>
  89. <dd><p>Use Pierre L’Ecuyers’ and Richard Simard’s RngStreams.</p>
  90. <div class="admonition seealso">
  91. <p class="first admonition-title">See also</p>
  92. <p class="last"><a class="reference external" href="http://statmath.wu.ac.at/software/RngStreams/">http://statmath.wu.ac.at/software/RngStreams/</a></p>
  93. </div>
  94. </dd></dl>
  95. </dd></dl>
  96. <dl class="data">
  97. <dt id="pypdevsbbl.extra.rngstreams.GENERATE_WITH">
  98. <code class="descclassname">pypdevsbbl.extra.rngstreams.</code><code class="descname">GENERATE_WITH</code><em class="property"> = &lt;Generators.RANDOM: 0&gt;</em><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.GENERATE_WITH" title="Permalink to this definition">¶</a></dt>
  99. <dd><p>Identifies the stream to use.</p>
  100. <p>Set this value to the desired RNG stream, before the model is constructed.
  101. 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>
  102. </dd></dl>
  103. <dl class="function">
  104. <dt id="pypdevsbbl.extra.rngstreams.setGeneratorType">
  105. <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>
  106. <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>
  107. <p>Call this function to validly set the generator type.</p>
  108. <div class="admonition seealso">
  109. <p class="first admonition-title">See also</p>
  110. <ul class="last simple">
  111. <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>
  112. <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>
  113. </ul>
  114. </div>
  115. <div class="admonition note">
  116. <p class="first admonition-title">Note</p>
  117. <p class="last">May be changed during construction of RNG-dependent building blocks.
  118. This allows the combination of multiple generator types.</p>
  119. </div>
  120. </dd></dl>
  121. <dl class="class">
  122. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState">
  123. <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>
  124. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">_ctypes.Structure</span></code></p>
  125. <dl class="attribute">
  126. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Anti">
  127. <code class="descname">Anti</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Anti" title="Permalink to this definition">¶</a></dt>
  128. <dd><p>Structure/Union member</p>
  129. </dd></dl>
  130. <dl class="attribute">
  131. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Bg">
  132. <code class="descname">Bg</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Bg" title="Permalink to this definition">¶</a></dt>
  133. <dd><p>Structure/Union member</p>
  134. </dd></dl>
  135. <dl class="attribute">
  136. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Cg">
  137. <code class="descname">Cg</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Cg" title="Permalink to this definition">¶</a></dt>
  138. <dd><p>Structure/Union member</p>
  139. </dd></dl>
  140. <dl class="attribute">
  141. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.Ig">
  142. <code class="descname">Ig</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.Ig" title="Permalink to this definition">¶</a></dt>
  143. <dd><p>Structure/Union member</p>
  144. </dd></dl>
  145. <dl class="attribute">
  146. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.IncPrec">
  147. <code class="descname">IncPrec</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.IncPrec" title="Permalink to this definition">¶</a></dt>
  148. <dd><p>Structure/Union member</p>
  149. </dd></dl>
  150. <dl class="attribute">
  151. <dt id="pypdevsbbl.extra.rngstreams.RngStream_InfoState.name">
  152. <code class="descname">name</code><a class="headerlink" href="#pypdevsbbl.extra.rngstreams.RngStream_InfoState.name" title="Permalink to this definition">¶</a></dt>
  153. <dd><p>Structure/Union member</p>
  154. </dd></dl>
  155. </dd></dl>
  156. <dl class="function">
  157. <dt id="pypdevsbbl.extra.rngstreams.setSeed">
  158. <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>
  159. <dd><p>Sets a new seed for the RngStreams generator object.</p>
  160. <p>RngStream requires a seed that is of size 6. This function makes it
  161. easier in a sense that when it does not find enough values for its seed,
  162. it will automatically fill the seed until it is large enough.</p>
  163. <table class="docutils field-list" frame="void" rules="none">
  164. <col class="field-name" />
  165. <col class="field-body" />
  166. <tbody valign="top">
  167. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  168. <li><strong>gen</strong> (<em>object</em>) – The generator object (RngStreams).</li>
  169. <li><strong>seed</strong> – Either a numeric, or an iterable.
  170. The new seed to use.</li>
  171. </ul>
  172. </td>
  173. </tr>
  174. <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>
  175. </td>
  176. </tr>
  177. <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>
  178. </td>
  179. </tr>
  180. </tbody>
  181. </table>
  182. </dd></dl>
  183. <dl class="function">
  184. <dt id="pypdevsbbl.extra.rngstreams.createStream">
  185. <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>
  186. <dd><p>Creates a custom RNG stream, w.r.t. the requested generator.</p>
  187. <table class="docutils field-list" frame="void" rules="none">
  188. <col class="field-name" />
  189. <col class="field-body" />
  190. <tbody valign="top">
  191. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
  192. <li><strong>name</strong> (<em>str</em>) – The unique name in case of an RngStreams generator.</li>
  193. <li><strong>seed</strong> – Either a numeric, or an iterable. The seed to use.
  194. When <code class="docutils literal notranslate"><span class="pre">None</span></code>, no seed will be set. Defaults to
  195. <code class="docutils literal notranslate"><span class="pre">None</span></code>.</li>
  196. </ul>
  197. </td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. </dd></dl>
  202. <dl class="function">
  203. <dt id="pypdevsbbl.extra.rngstreams.U01">
  204. <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>
  205. <dd><p>Return a uniformly distributed random variable within (0, 1).</p>
  206. <p>This function works no matter the selected generator.</p>
  207. <table class="docutils field-list" frame="void" rules="none">
  208. <col class="field-name" />
  209. <col class="field-body" />
  210. <tbody valign="top">
  211. <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>
  212. </tr>
  213. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A numpy.float64 in the range (0, 1).</td>
  214. </tr>
  215. </tbody>
  216. </table>
  217. </dd></dl>
  218. <div class="section" id="submodules">
  219. <h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
  220. <div class="toctree-wrapper compound">
  221. <ul>
  222. <li class="toctree-l1"><a class="reference internal" href="pypdevsbbl.extra.rngstreams.distributions.html">pypdevsbbl.extra.rngstreams.distributions module</a></li>
  223. </ul>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  231. <div class="sphinxsidebarwrapper">
  232. <h4>Previous topic</h4>
  233. <p class="topless"><a href="pypdevsbbl.extra.html"
  234. title="previous chapter">pypdevsbbl.extra package</a></p>
  235. <h4>Next topic</h4>
  236. <p class="topless"><a href="pypdevsbbl.extra.rngstreams.distributions.html"
  237. title="next chapter">pypdevsbbl.extra.rngstreams.distributions module</a></p>
  238. <div id="searchbox" style="display: none" role="search">
  239. <h3>Quick search</h3>
  240. <div class="searchformwrapper">
  241. <form class="search" action="search.html" method="get">
  242. <input type="text" name="q" />
  243. <input type="submit" value="Go" />
  244. <input type="hidden" name="check_keywords" value="yes" />
  245. <input type="hidden" name="area" value="default" />
  246. </form>
  247. </div>
  248. </div>
  249. <script type="text/javascript">$('#searchbox').show(0);</script>
  250. </div>
  251. </div>
  252. <div class="clearer"></div>
  253. </div>
  254. <div class="related" role="navigation" aria-label="related navigation">
  255. <h3>Navigation</h3>
  256. <ul>
  257. <li class="right" style="margin-right: 10px">
  258. <a href="genindex.html" title="General Index"
  259. >index</a></li>
  260. <li class="right" >
  261. <a href="py-modindex.html" title="Python Module Index"
  262. >modules</a> |</li>
  263. <li class="right" >
  264. <a href="pypdevsbbl.extra.rngstreams.distributions.html" title="pypdevsbbl.extra.rngstreams.distributions module"
  265. >next</a> |</li>
  266. <li class="right" >
  267. <a href="pypdevsbbl.extra.html" title="pypdevsbbl.extra package"
  268. >previous</a> |</li>
  269. <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> &#187;</li>
  270. <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> &#187;</li>
  271. <li class="nav-item nav-item-2"><a href="pypdevsbbl.extra.html" >pypdevsbbl.extra package</a> &#187;</li>
  272. </ul>
  273. </div>
  274. <div class="footer" role="contentinfo">
  275. &#169; Copyright 2020, Randy Paredis.
  276. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
  277. </div>
  278. </body>
  279. </html>