<!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="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>libstdc++: std::binomial_distribution< _IntType > Class Template Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">libstdc++</div> </td> </tr> </tbody> </table> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('a00411.html',''); </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> | <a href="#pub-types">Public Types</a> | <a href="#pub-methods">Public Member Functions</a> | <a href="#friends">Friends</a> </div> <div class="headertitle"> <div class="title">std::binomial_distribution< _IntType > Class Template Reference<div class="ingroups"><a class="el" href="a01210.html">Bernoulli Distributions</a></div></div> </div> </div> <div class="contents"> <!-- doxytag: class="std::binomial_distribution" --> <p>A discrete binomial random number distribution. <a href="a00411.html#details">More...</a></p> <p><a href="a01934.html">List of all members.</a></p> <h2><a name="nested-classes"></a> Classes</h2> <ul> <li>struct <a class="el" href="a00412.html">param_type</a> </ul> <h2><a name="pub-types"></a> Public Types</h2> <ul> <li>typedef _IntType <a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> </ul> <h2><a name="pub-methods"></a> Public Member Functions</h2> <ul> <li><a class="anchor" id="a63c86a8536c99789998e0d2caadf3a9d"></a><!-- doxytag: member="std::binomial_distribution::binomial_distribution" ref="a63c86a8536c99789998e0d2caadf3a9d" args="(_IntType __t=_IntType(1), double __p=0.5)" --> <b>binomial_distribution</b> (_IntType __t=_IntType(1), double __p=0.5) <li><a class="anchor" id="a2f3e837eb3daff4b56da776f7aa68a3f"></a><!-- doxytag: member="std::binomial_distribution::binomial_distribution" ref="a2f3e837eb3daff4b56da776f7aa68a3f" args="(const param_type &__p)" --> <b>binomial_distribution</b> (const <a class="el" href="a00412.html">param_type</a> &__p) <li><a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html#aa72944ad58c9b9f8879ddc546431efd1">max</a> () const <li><a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html#a2a5316527d0664d36f848b4cc8a0d45e">min</a> () const <li>template<typename _UniformRandomNumberGenerator > <a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html#a83f6cb4bf61ca2313e40e6d998db8ffd">operator()</a> (_UniformRandomNumberGenerator &__urng, const <a class="el" href="a00412.html">param_type</a> &__p) <li>template<typename _UniformRandomNumberGenerator > <a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html#ae95d3b0b0c5f9556018a4da7a31d2efa">operator()</a> (_UniformRandomNumberGenerator &__urng) <li>double <a class="el" href="a00411.html#aeb3fbc69ecb5ada1a85ac1527afb6055">p</a> () const <li>void <a class="el" href="a00411.html#a77ced711f56a6b1dabc97cae8c0e70d7">param</a> (const <a class="el" href="a00412.html">param_type</a> &__param) <li><a class="el" href="a00412.html">param_type</a> <a class="el" href="a00411.html#ab4afe25fdde270d737ac4b87db07060b">param</a> () const <li>void <a class="el" href="a00411.html#acac7f32aa4a2b3ac2e512c5097aa70dc">reset</a> () <li>_IntType <a class="el" href="a00411.html#abc09c4b4af30f83308093db5c49c2991">t</a> () const </ul> <h2><a name="friends"></a> Friends</h2> <ul> <li>template<typename _IntType1 , typename _CharT , typename _Traits > <a class="el" href="a00251.html">std::basic_ostream</a>< _CharT, <br class="typebreak"/> _Traits > & <a class="el" href="a00411.html#a2737dffad68b5539ed3d992aa1f0e967">operator<<</a> (<a class="el" href="a00251.html">std::basic_ostream</a>< _CharT, _Traits > &, const <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > &) <li>template<typename _IntType1 > bool <a class="el" href="a00411.html#a9b8f99a3ede2f370a8931b002d354730">operator==</a> (const <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > &__d1, const <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > &__d2) <li>template<typename _IntType1 , typename _CharT , typename _Traits > <a class="el" href="a00250.html">std::basic_istream</a>< _CharT, <br class="typebreak"/> _Traits > & <a class="el" href="a00411.html#a698074fe7cab9cb9468d89178e4f82f1">operator>></a> (<a class="el" href="a00250.html">std::basic_istream</a>< _CharT, _Traits > &, <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > &) </ul> <hr/><a name="details" id="details"></a><h2>Detailed Description</h2> <div class="textblock"><h3>template<typename _IntType = int><br/> class std::binomial_distribution< _IntType ></h3> <p>A discrete binomial random number distribution. </p> <p>The formula for the binomial probability density function is <img class="formulaInl" alt="$p(i|t,p) = \binom{n}{i} p^i (1 - p)^{t - i}$" src="form_15.png"/> where <img class="formulaInl" alt="$t$" src="form_16.png"/> and <img class="formulaInl" alt="$p$" src="form_13.png"/> are the parameters of the distribution. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03399">3399</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div><hr/><h2>Member Typedef Documentation</h2> <a class="anchor" id="af4383227c82a6c0ee7d105c6b9bad120"></a><!-- doxytag: member="std::binomial_distribution::result_type" ref="af4383227c82a6c0ee7d105c6b9bad120" args="" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname">typedef _IntType <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::<a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a></td> </tr> </table> </div> <div class="memdoc"> <p>The type of the range of the distribution. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03406">3406</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="aa72944ad58c9b9f8879ddc546431efd1"></a><!-- doxytag: member="std::binomial_distribution::max" ref="aa72944ad58c9b9f8879ddc546431efd1" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::max </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const<code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the least upper bound value of the distribution. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03509">3509</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <a class="anchor" id="a2a5316527d0664d36f848b4cc8a0d45e"></a><!-- doxytag: member="std::binomial_distribution::min" ref="a2a5316527d0664d36f848b4cc8a0d45e" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::min </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const<code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the greatest lower bound value of the distribution. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03502">3502</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <a class="anchor" id="ae95d3b0b0c5f9556018a4da7a31d2efa"></a><!-- doxytag: member="std::binomial_distribution::operator()" ref="ae95d3b0b0c5f9556018a4da7a31d2efa" args="(_UniformRandomNumberGenerator &__urng)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <div class="memtemplate"> template<typename _UniformRandomNumberGenerator > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::operator() </td> <td>(</td> <td class="paramtype">_UniformRandomNumberGenerator & </td> <td class="paramname"><em>__urng</em></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Generating functions. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03517">3517</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> <p>References <a class="el" href="a00997_source.html#l03517">std::binomial_distribution< _IntType >::operator()()</a>, and <a class="el" href="a00997_source.html#l03487">std::binomial_distribution< _IntType >::param()</a>.</p> <p>Referenced by <a class="el" href="a00997_source.html#l03517">std::binomial_distribution< _IntType >::operator()()</a>.</p> </div> </div> <a class="anchor" id="a83f6cb4bf61ca2313e40e6d998db8ffd"></a><!-- doxytag: member="std::binomial_distribution::operator()" ref="a83f6cb4bf61ca2313e40e6d998db8ffd" args="(_UniformRandomNumberGenerator &__urng, const param_type &__p)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType > </div> <div class="memtemplate"> template<typename _UniformRandomNumberGenerator > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00411.html">binomial_distribution</a>< _IntType >::<a class="el" href="a00411.html#af4383227c82a6c0ee7d105c6b9bad120">result_type</a> <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::operator() </td> <td>(</td> <td class="paramtype">_UniformRandomNumberGenerator & </td> <td class="paramname"><em>__urng</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="a00412.html">param_type</a> & </td> <td class="paramname"><em>__param</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>A rejection algorithm when t * p >= 8 and a simple waiting time method - the second in the referenced book - otherwise. NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1 is defined.</p> <p>Reference: Devroye, L. Non-Uniform Random Variates Generation. Springer-Verlag, New York, 1986, Ch. X, Sect. 4 (+ Errata!). </p> <p>Definition at line <a class="el" href="a00998_source.html#l01434">1434</a> of file <a class="el" href="a00998_source.html">random.tcc</a>.</p> <p>References <a class="el" href="a00812_source.html#l00596">std::abs()</a>, <a class="el" href="a00812_source.html#l00784">std::log()</a>, and <a class="el" href="a00997_source.html#l04051">std::poisson_distribution< _IntType >::max()</a>.</p> </div> </div> <a class="anchor" id="aeb3fbc69ecb5ada1a85ac1527afb6055"></a><!-- doxytag: member="std::binomial_distribution::p" ref="aeb3fbc69ecb5ada1a85ac1527afb6055" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname">double <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::p </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const<code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the distribution <code>p</code> parameter. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03480">3480</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <a class="anchor" id="a77ced711f56a6b1dabc97cae8c0e70d7"></a><!-- doxytag: member="std::binomial_distribution::param" ref="a77ced711f56a6b1dabc97cae8c0e70d7" args="(const param_type &__param)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::param </td> <td>(</td> <td class="paramtype">const <a class="el" href="a00412.html">param_type</a> & </td> <td class="paramname"><em>__param</em></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Sets the parameter set of the distribution. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">__param</td><td>The new parameter set of the distribution. </td></tr> </table> </dd> </dl> <p>Definition at line <a class="el" href="a00997_source.html#l03495">3495</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <a class="anchor" id="ab4afe25fdde270d737ac4b87db07060b"></a><!-- doxytag: member="std::binomial_distribution::param" ref="ab4afe25fdde270d737ac4b87db07060b" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00412.html">param_type</a> <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::param </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const<code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the parameter set of the distribution. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03487">3487</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> <p>Referenced by <a class="el" href="a00997_source.html#l03517">std::binomial_distribution< _IntType >::operator()()</a>.</p> </div> </div> <a class="anchor" id="acac7f32aa4a2b3ac2e512c5097aa70dc"></a><!-- doxytag: member="std::binomial_distribution::reset" ref="acac7f32aa4a2b3ac2e512c5097aa70dc" args="()" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname">void <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::reset </td> <td>(</td> <td class="paramname"></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Resets the distribution state. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03466">3466</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> <p>References <a class="el" href="a00997_source.html#l02031">std::normal_distribution< _RealType >::reset()</a>.</p> </div> </div> <a class="anchor" id="abc09c4b4af30f83308093db5c49c2991"></a><!-- doxytag: member="std::binomial_distribution::t" ref="abc09c4b4af30f83308093db5c49c2991" args="() const " --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <table class="memname"> <tr> <td class="memname">_IntType <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType >::t </td> <td>(</td> <td class="paramname"></td><td>)</td> <td> const<code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Returns the distribution <code>t</code> parameter. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03473">3473</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <hr/><h2>Friends And Related Function Documentation</h2> <a class="anchor" id="a2737dffad68b5539ed3d992aa1f0e967"></a><!-- doxytag: member="std::binomial_distribution::operator<<" ref="a2737dffad68b5539ed3d992aa1f0e967" args="(std::basic_ostream< _CharT, _Traits > &, const std::binomial_distribution< _IntType1 > &)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <div class="memtemplate"> template<typename _IntType1 , typename _CharT , typename _Traits > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00251.html">std::basic_ostream</a><_CharT, _Traits>& operator<< </td> <td>(</td> <td class="paramtype"><a class="el" href="a00251.html">std::basic_ostream</a>< _CharT, _Traits > & </td> <td class="paramname">, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > & </td> <td class="paramname"> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [friend]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Inserts a binomial_distribution random number distribution <code>__x</code> into the output stream <code>__os</code>. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">__os</td><td>An output stream. </td></tr> <tr><td class="paramname">__x</td><td>A binomial_distribution random number distribution.</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>The output stream with the state of <code>__x</code> inserted or in an error state. </dd></dl> </div> </div> <a class="anchor" id="a9b8f99a3ede2f370a8931b002d354730"></a><!-- doxytag: member="std::binomial_distribution::operator==" ref="a9b8f99a3ede2f370a8931b002d354730" args="(const std::binomial_distribution< _IntType1 > &__d1, const std::binomial_distribution< _IntType1 > &__d2)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <div class="memtemplate"> template<typename _IntType1 > </div> <table class="memname"> <tr> <td class="memname">bool operator== </td> <td>(</td> <td class="paramtype">const <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > & </td> <td class="paramname"><em>__d1</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > & </td> <td class="paramname"><em>__d2</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [friend]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Return true if two binomial distributions have the same parameters and the sequences that would be generated are equal. </p> <p>Definition at line <a class="el" href="a00997_source.html#l03532">3532</a> of file <a class="el" href="a00997_source.html">random.h</a>.</p> </div> </div> <a class="anchor" id="a698074fe7cab9cb9468d89178e4f82f1"></a><!-- doxytag: member="std::binomial_distribution::operator>>" ref="a698074fe7cab9cb9468d89178e4f82f1" args="(std::basic_istream< _CharT, _Traits > &, std::binomial_distribution< _IntType1 > &)" --> <div class="memitem"> <div class="memproto"> <div class="memtemplate"> template<typename _IntType = int> </div> <div class="memtemplate"> template<typename _IntType1 , typename _CharT , typename _Traits > </div> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00250.html">std::basic_istream</a><_CharT, _Traits>& operator>> </td> <td>(</td> <td class="paramtype"><a class="el" href="a00250.html">std::basic_istream</a>< _CharT, _Traits > & </td> <td class="paramname">, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="a00411.html">std::binomial_distribution</a>< _IntType1 > & </td> <td class="paramname"> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [friend]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Extracts a binomial_distribution random number distribution <code>__x</code> from the input stream <code>__is</code>. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">__is</td><td>An input stream. </td></tr> <tr><td class="paramname">__x</td><td>A binomial_distribution random number generator engine.</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>The input stream with <code>__x</code> extracted or in an error state. </dd></dl> </div> </div> <hr/>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="a00997_source.html">random.h</a></li> <li><a class="el" href="a00998_source.html">random.tcc</a></li> </ul> </div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="a01137.html">std</a> </li> <li class="navelem"><a class="el" href="a00411.html">binomial_distribution</a> </li> <li class="footer">Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li> </ul> </div> </body> </html>