variates.html 5.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Random Variates and Distribution Parameters</title>
  5. <link rel="stylesheet" href="../../math.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../../index.html" title="Math Toolkit 2.11.0">
  8. <link rel="up" href="../stat_tut.html" title="Statistical Distributions Tutorial">
  9. <link rel="prev" href="weg/c_sharp.html" title="Using the Distributions from Within C#">
  10. <link rel="next" href="dist_params.html" title="Discrete Probability Distributions">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="weg/c_sharp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../stat_tut.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dist_params.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h3 class="title">
  27. <a name="math_toolkit.stat_tut.variates"></a><a class="link" href="variates.html" title="Random Variates and Distribution Parameters">Random Variates and Distribution
  28. Parameters</a>
  29. </h3></div></div></div>
  30. <p>
  31. <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">Random variates</a>
  32. and <a href="http://en.wikipedia.org/wiki/Parameter" target="_top">distribution parameters</a>
  33. are conventionally distinguished (for example in Wikipedia and Wolfram MathWorld
  34. by placing a semi-colon after the <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
  35. variate</a> (whose value you 'choose'), to separate the variate from
  36. the parameter(s) that defines the shape of the distribution.
  37. </p>
  38. <p>
  39. For example, the binomial distribution has two parameters: n (the number
  40. of trials) and p (the probability of success on one trial). It also has the
  41. <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random variate</a>
  42. <span class="emphasis"><em>k</em></span>: the number of successes observed. This means the
  43. probability density/mass function (pdf) is written as <span class="emphasis"><em>f(k; n, p)</em></span>.
  44. </p>
  45. <p>
  46. Translating this into code the <code class="computeroutput"><span class="identifier">binomial_distribution</span></code>
  47. constructor therefore has two parameters:
  48. </p>
  49. <pre class="programlisting"><span class="identifier">binomial_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">p</span><span class="special">);</span>
  50. </pre>
  51. <p>
  52. While the function <code class="computeroutput"><span class="identifier">pdf</span></code> has
  53. one argument specifying the distribution type (which includes its parameters,
  54. if any), and a second argument for the <a href="http://en.wikipedia.org/wiki/Random_variate" target="_top">random
  55. variate</a>. So taking our binomial distribution example, we would write:
  56. </p>
  57. <pre class="programlisting"><span class="identifier">pdf</span><span class="special">(</span><span class="identifier">binomial_distribution</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;(</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">p</span><span class="special">),</span> <span class="identifier">k</span><span class="special">);</span>
  58. </pre>
  59. </div>
  60. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  61. <td align="left"></td>
  62. <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
  63. Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
  64. Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
  65. R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
  66. Daryle Walker and Xiaogang Zhang<p>
  67. Distributed under the Boost Software License, Version 1.0. (See accompanying
  68. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  69. </p>
  70. </div></td>
  71. </tr></table>
  72. <hr>
  73. <div class="spirit-nav">
  74. <a accesskey="p" href="weg/c_sharp.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../stat_tut.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="dist_params.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
  75. </div>
  76. </body>
  77. </html>