Documentation for 0931d530ae
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.5"/>
|
||||
<meta name="generator" content="Doxygen 1.9.6"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: probability/binomial_dist.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.5 -->
|
||||
<!-- Generated by Doxygen 1.9.6 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
@@ -132,9 +132,9 @@ Functions</h2></td></tr>
|
||||
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p ><a href="https://en.wikipedia.org/wiki/Binomial_distribution" target="_blank">Binomial distribution</a> example </p>
|
||||
<p >The binomial distribution models the number of successes in a sequence of n independent events</p>
|
||||
<p >Summary of variables used:</p><ul>
|
||||
<div class="textblock"><p><a href="https://en.wikipedia.org/wiki/Binomial_distribution" target="_blank">Binomial distribution</a> example </p>
|
||||
<p>The binomial distribution models the number of successes in a sequence of n independent events</p>
|
||||
<p>Summary of variables used:</p><ul>
|
||||
<li>n : number of trials</li>
|
||||
<li>p : probability of success</li>
|
||||
<li>x : desired successes </li>
|
||||
@@ -165,7 +165,7 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >finds the expected value of a binomial distribution </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<p>finds the expected value of a binomial distribution </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">n</td><td></td></tr>
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">p</td><td></td></tr>
|
||||
@@ -214,7 +214,7 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >calculates the probability of a result within a range (inclusive, inclusive) </p><dl class="section return"><dt>Returns</dt><dd>\(\displaystyle \left.P(n,p)\right|_{x_0}^{x_1} =
|
||||
<p>calculates the probability of a result within a range (inclusive, inclusive) </p><dl class="section return"><dt>Returns</dt><dd>\(\displaystyle \left.P(n,p)\right|_{x_0}^{x_1} =
|
||||
\sum_{i=x_0}^{x_1} P(i)
|
||||
=\sum_{i=x_0}^{x_1} {n\choose i} p^i (1-p)^{n-i}\) </dd></dl>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 75</span> {</div>
|
||||
@@ -262,7 +262,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >finds the standard deviation of the binomial distribution </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<p>finds the standard deviation of the binomial distribution </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">n</td><td></td></tr>
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">p</td><td></td></tr>
|
||||
@@ -309,7 +309,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >finds the variance of the binomial distribution </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<p>finds the variance of the binomial distribution </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">n</td><td></td></tr>
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">p</td><td></td></tr>
|
||||
@@ -352,7 +352,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >calculates the probability of exactly x successes </p><dl class="section return"><dt>Returns</dt><dd>\(\displaystyle P(n,p,x) = {n\choose x} p^x (1-p)^{n-x}\) </dd></dl>
|
||||
<p>calculates the probability of exactly x successes </p><dl class="section return"><dt>Returns</dt><dd>\(\displaystyle P(n,p,x) = {n\choose x} p^x (1-p)^{n-x}\) </dd></dl>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 65</span> {</div>
|
||||
<div class="line"><span class="lineno"> 66</span> <span class="keywordflow">return</span> <a class="code hl_function" href="../../d6/db0/binomial__dist_8cpp.html#a78d36635232e54b5d71fcbf1eac9a49a">nCr</a>(n, x) * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(p, x) * <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(1 - p, n - x);</div>
|
||||
<div class="line"><span class="lineno"> 67</span>}</div>
|
||||
@@ -380,7 +380,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >main function </p>
|
||||
<p>main function </p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 84</span> {</div>
|
||||
<div class="line"><span class="lineno"> 85</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"expected value : "</span> << <a class="code hl_function" href="../../d6/db0/binomial__dist_8cpp.html#a4416a7bc7fa87201883c54cdc4c82813">binomial_expected</a>(100, 0.5)</div>
|
||||
<div class="line"><span class="lineno"> 86</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
@@ -438,7 +438,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Computes n choose r </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<p>Computes n choose r </p><dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">n</td><td></td></tr>
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">r</td><td></td></tr>
|
||||
@@ -471,7 +471,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_82e494173a87936756866de2fa774307.html">probability</a></li><li class="navelem"><a class="el" href="../../d6/db0/binomial__dist_8cpp.html">binomial_dist.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
|
||||
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
|
||||
-->
|
||||
<!-- Title: binomial_x_successes Pages: 1 -->
|
||||
<svg width="214pt" height="64pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
|
||||
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
|
||||
-->
|
||||
<!-- Title: binomial_range_successes Pages: 1 -->
|
||||
<svg width="232pt" height="64pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
|
||||
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="353pt" height="214pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 7.0.4 (20221203.1631)
|
||||
<!-- Generated by graphviz version 7.0.6 (20230106.0513)
|
||||
-->
|
||||
<!-- Title: binomial_standard_deviation Pages: 1 -->
|
||||
<svg width="279pt" height="64pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |