mtwist-calling-conventions.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on November 8, 2012 by texi2html 1.82
  4. texi2html was written by:
  5. Lionel Cons <[email protected]> (original author)
  6. Karl Berry <[email protected]>
  7. Olaf Bachmann <[email protected]>
  8. and many others.
  9. Maintained by: Many creative people.
  10. Send bugs and suggestions to <[email protected]>
  11. -->
  12. <head>
  13. <title>avram - a virtual machine code interpreter: D.12.1 mtwist calling conventions</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: D.12.1 mtwist calling conventions">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: D.12.1 mtwist calling conventions">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="texi2html 1.82">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <style type="text/css">
  21. <!--
  22. a.summary-letter {text-decoration: none}
  23. blockquote.smallquotation {font-size: smaller}
  24. pre.display {font-family: serif}
  25. pre.format {font-family: serif}
  26. pre.menu-comment {font-family: serif}
  27. pre.menu-preformatted {font-family: serif}
  28. pre.smalldisplay {font-family: serif; font-size: smaller}
  29. pre.smallexample {font-size: smaller}
  30. pre.smallformat {font-family: serif; font-size: smaller}
  31. pre.smalllisp {font-size: smaller}
  32. span.roman {font-family:serif; font-weight:normal;}
  33. span.sansserif {font-family:sans-serif; font-weight:normal;}
  34. ul.toc {list-style: none}
  35. -->
  36. </style>
  37. </head>
  38. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  39. <a name="mtwist-calling-conventions"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="mtwist.html#mtwist" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="mtwist-exceptions.html#mtwist-exceptions" title="Next section in reading order"> &gt; </a>]</td>
  43. <td valign="middle" align="left"> &nbsp; </td>
  44. <td valign="middle" align="left">[<a href="External-Libraries.html#External-Libraries" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  45. <td valign="middle" align="left">[<a href="mtwist.html#mtwist" title="Up section"> Up </a>]</td>
  46. <td valign="middle" align="left">[<a href="Copying.html#Copying" title="Next chapter"> &gt;&gt; </a>]</td>
  47. <td valign="middle" align="left"> &nbsp; </td>
  48. <td valign="middle" align="left"> &nbsp; </td>
  49. <td valign="middle" align="left"> &nbsp; </td>
  50. <td valign="middle" align="left"> &nbsp; </td>
  51. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  52. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  53. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  54. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  55. </tr></table>
  56. <hr size="1">
  57. <a name="mtwist-calling-conventions-1"></a>
  58. <h3 class="subsection">D.12.1 <code>mtwist</code> calling conventions</h3>
  59. <p>All of the functions in this library simulate a random draw from a
  60. distribution. There is a choice of distribution statistics depending
  61. on the function used.
  62. </p>
  63. <dl compact="compact">
  64. <dt> <code>bern</code></dt>
  65. <dd><p>takes a floating point number <var>p</var> between 0 and 1, encoded as in
  66. <a href="math.html#math"><code>math</code></a>, and returns a boolean value, either <code>(nil,nil)</code> for
  67. true or <code>nil</code> for false. A true value is returned only if a
  68. random draw from a uniform distribution ranging from 0 to 1 is less
  69. than <var>p</var>. This function therefore simulates a draw from a
  70. Bernoulli distribution. A <code>nil</code> value of <var>p</var> is treated as
  71. 1/2.
  72. </p></dd>
  73. <dt> <code>u_cont</code></dt>
  74. <dd><p>takes a floating point number <var>x</var> as an
  75. argument, and returns a random draw from a continuous uniform
  76. distribution ranging from 0 to <var>x</var>. A <code>nil</code> value of <var>x</var>
  77. is treated as unity.
  78. </p></dd>
  79. <dt> <code>u_disc</code></dt>
  80. <dd><p>simulates a draw from a uniform discrete distribution whose domain
  81. is the set of natural numbers from 0 to <var>n</var> - 1. The number <var>n</var>
  82. is given as a parameter to this function, and the retuned value
  83. is the draw.
  84. </p>
  85. <ul>
  86. <li>
  87. The returned value will have at most 64 bits regardless of <var>n</var>.
  88. </li><li>
  89. Natural numbers are encoded as described in
  90. <a href="Representation-of-Numeric-and-Textual-Data.html#Representation-of-Numeric-and-Textual-Data">Representation of Numeric and Textual Data</a>.
  91. </li><li>
  92. If a value of 0 is passed for <var>n</var>, the full 64 bit range is
  93. used.
  94. </li></ul>
  95. </dd>
  96. <dt> <code>u_path</code></dt>
  97. <dd><p>takes a pair of natural numbers <code>(<var>n</var>,<var>m</var>)</code> and returns a
  98. randomly chosen tree (<a href="Raw-Material.html#Raw-Material">Raw Material</a>) with 1 leaf and <var>n</var>
  99. non-leaves each having either a left or a right descendent but not
  100. both. The number <var>m</var> constrains the result to fall within the
  101. first <var>m</var> - 1 trees of this form enumerated by exhausting all
  102. possibilities at lower levels before admitting a right descendent at a
  103. higher level. Within these criteria, all possible results are equally
  104. probable. Both numbers are masked to 64 bits, but if <var>m</var> is zero,
  105. it is treated as 2^<var>n</var>.
  106. </p></dd>
  107. <dt> <code>u_enum</code></dt>
  108. <dd><p>simulates a random draw from a uniform discrete distribution whose
  109. domain is enumerated. The argument to the function is a non-empty list,
  110. and the result is an item selected from the list, with all choices
  111. being equally probable.
  112. </p></dd>
  113. <dt> <code>w_disc</code></dt>
  114. <dd><p>simulates a random draw from a non-uniform, or &ldquo;weighted&rdquo; discrete
  115. distribution whose domain is a set of consecutive natural numbers
  116. starting from zero. The argument to the function is a list giving the
  117. probability of each outcome starting from zero as a floating point
  118. number. Probabilities must be non-negative but needn&rsquo;t be normalized.
  119. </p></dd>
  120. <dt> <code>w_enum</code></dt>
  121. <dd><p>simulates a random draw from a non-uniform, or &ldquo;weighted&rdquo; discrete
  122. distribution with an arbitrary domain enumerated in the argument. The
  123. argument is a list of pairs <code>&lt;(<var>x</var>,<var>p</var>)..&gt;</code>, where
  124. <var>x</var> is a possible outcome and <var>p</var> is its probability. The
  125. result returned is one of the values of <var>x</var> from the input list
  126. chosen at random according to the associated
  127. probability. Probabilities must be non-negative but needn&rsquo;t be
  128. normalized.
  129. </p></dd>
  130. </dl>
  131. <hr size="1">
  132. <table cellpadding="1" cellspacing="1" border="0">
  133. <tr><td valign="middle" align="left">[<a href="mtwist.html#mtwist" title="Previous section in reading order"> &lt; </a>]</td>
  134. <td valign="middle" align="left">[<a href="mtwist-exceptions.html#mtwist-exceptions" title="Next section in reading order"> &gt; </a>]</td>
  135. <td valign="middle" align="left"> &nbsp; </td>
  136. <td valign="middle" align="left">[<a href="External-Libraries.html#External-Libraries" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  137. <td valign="middle" align="left">[<a href="mtwist.html#mtwist" title="Up section"> Up </a>]</td>
  138. <td valign="middle" align="left">[<a href="Copying.html#Copying" title="Next chapter"> &gt;&gt; </a>]</td>
  139. <td valign="middle" align="left"> &nbsp; </td>
  140. <td valign="middle" align="left"> &nbsp; </td>
  141. <td valign="middle" align="left"> &nbsp; </td>
  142. <td valign="middle" align="left"> &nbsp; </td>
  143. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  144. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  145. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  146. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  147. </tr></table>
  148. <p>
  149. <font size="-1">
  150. This document was generated on <i>November 8, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  151. </font>
  152. <br>
  153. </p>
  154. </body>
  155. </html>