mtwist-calling-conventions.html 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <html lang="en">
  2. <head>
  3. <title>mtwist calling conventions - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="mtwist.html#mtwist" title="mtwist">
  9. <link rel="prev" href="mtwist.html#mtwist" title="mtwist">
  10. <link rel="next" href="mtwist-exceptions.html#mtwist-exceptions" title="mtwist exceptions">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="mtwist-calling-conventions"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="mtwist-exceptions.html#mtwist-exceptions">mtwist exceptions</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="mtwist.html#mtwist">mtwist</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="mtwist.html#mtwist">mtwist</a>
  32. <hr>
  33. </div>
  34. <h4 class="subsection">D.12.1 <code>mtwist</code> calling conventions</h4>
  35. <p>All of the functions in this library simulate a random draw from a
  36. distribution. There is a choice of distribution statistics depending
  37. on the function used.
  38. <dl>
  39. <dt><code>bern</code><dd>takes a floating point number <var>p</var> between 0 and 1, encoded as in
  40. <a href="math.html#math">math</a>, and returns a boolean value, either <code>(nil,nil)</code> for
  41. true or <code>nil</code> for false. A true value is returned only if a
  42. random draw from a uniform distribution ranging from 0 to 1 is less
  43. than <var>p</var>. This function therefore simulates a draw from a
  44. Bernoulli distribution. A <code>nil</code> value of <var>p</var> is treated as
  45. 1/2.
  46. <br><dt><code>u_cont</code><dd>takes a floating point number <var>x</var> as an
  47. argument, and returns a random draw from a continuous uniform
  48. distribution ranging from 0 to <var>x</var>. A <code>nil</code> value of <var>x</var>
  49. is treated as unity.
  50. <br><dt><code>u_disc</code><dd>simulates a draw from a uniform discrete distribution whose domain
  51. is the set of natural numbers from 0 to <var>n</var> - 1. The number <var>n</var>
  52. is given as a parameter to this function, and the retuned value
  53. is the draw.
  54. <ul>
  55. <li>The returned value will have at most 64 bits regardless of <var>n</var>.
  56. <li>Natural numbers are encoded as described in
  57. <a href="Representation-of-Numeric-and-Textual-Data.html#Representation-of-Numeric-and-Textual-Data">Representation of Numeric and Textual Data</a>.
  58. <li>If a value of 0 is passed for <var>n</var>, the full 64 bit range is
  59. used.
  60. </ul>
  61. <br><dt><code>u_path</code><dd>takes a pair of natural numbers <code>(</code><var>n</var><code>,</code><var>m</var><code>)</code> and returns a
  62. randomly chosen tree (<a href="Raw-Material.html#Raw-Material">Raw Material</a>) with 1 leaf and <var>n</var>
  63. non-leaves each having either a left or a right descendent but not
  64. both. The number <var>m</var> constrains the result to fall within the
  65. first <var>m</var> - 1 trees of this form enumerated by exhausting all
  66. possibilities at lower levels before admitting a right descendent at a
  67. higher level. Within these criteria, all possible results are equally
  68. probable. Both numbers are masked to 64 bits, but if <var>m</var> is zero,
  69. it is treated as 2^<var>n</var>.
  70. <br><dt><code>u_enum</code><dd>simulates a random draw from a uniform discrete distribution whose
  71. domain is enumerated. The argument to the function is a non-empty list,
  72. and the result is an item selected from the list, with all choices
  73. being equally probable.
  74. <br><dt><code>w_disc</code><dd>simulates a random draw from a non-uniform, or &ldquo;weighted&rdquo; discrete
  75. distribution whose domain is a set of consecutive natural numbers
  76. starting from zero. The argument to the function is a list giving the
  77. probability of each outcome starting from zero as a floating point
  78. number. Probabilities must be non-negative but needn't be normalized.
  79. <br><dt><code>w_enum</code><dd>simulates a random draw from a non-uniform, or &ldquo;weighted&rdquo; discrete
  80. distribution with an arbitrary domain enumerated in the argument. The
  81. argument is a list of pairs <code>&lt;(</code><var>x</var><code>,</code><var>p</var><code>)..&gt;</code>, where
  82. <var>x</var> is a possible outcome and <var>p</var> is its probability. The
  83. result returned is one of the values of <var>x</var> from the input list
  84. chosen at random according to the associated
  85. probability. Probabilities must be non-negative but needn't be
  86. normalized.
  87. </dl>
  88. </body></html>