1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
|
<!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" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Statistical Functions</title>
<link rel="stylesheet" href="../_static/quark.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="top" title="SpeedCrunch 0.12 documentation" href="../contents.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="next" title="IEEE-754 Functions" href="ieee754.html" />
<link rel="prev" title="Integer & Bitwise Arithmetic Functions" href="integer.html" />
</head>
<body role="document">
<table class="navbar navbar-top">
<tr>
<td width="50%">
<a class="nav-item nav-item-0"
href="../contents.html">SpeedCrunch 0.12 documentation</a> » <a class="nav-item nav-item-1"
href="index.html">Reference</a>
</td>
<td align="right" width="50%">
<a class="rel-item rel-item-1"
href="integer.html"
title="Integer & Bitwise Arithmetic Functions"
accesskey="P">previous</a>
|
<a class="rel-item rel-item-2"
href="ieee754.html"
title="IEEE-754 Functions"
accesskey="N">next</a>
|
<a class="rel-item rel-item-3"
href="../sc-functionindex.html"
title="Function Index"
>functions</a>
|
<a class="rel-item rel-item-4"
href="../genindex.html"
title="General Index"
accesskey="I">index</a>
</td>
</tr>
</table>
<div class="document">
<div class="documentwrapper">
<div class="body" role="main">
<div class="section" id="statistical-functions">
<h1>Statistical Functions</h1>
<div class="section" id="general">
<h2>General</h2>
<dl class="function">
<dt id="sc.average">
<code class="descname">average</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the arithmetic average of the arguments (sum of the arguments divided by their number). The arguments must share the same dimension.</p>
</dd></dl>
<dl class="function">
<dt id="sc.geomean">
<code class="descname">geomean</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the geometric mean of the arguments, defined by <code class="docutils literal"><span class="pre">product(x1;</span> <span class="pre">x2;</span> <span class="pre">...)^(1/n)</span></code> where <code class="docutils literal"><span class="pre">n</span></code> is the number of arguments. All the arguments may each have a different dimension. The geometric mean is useful for comparing sets of quantities that are very different in order of magnitude and even possibly dimension.</p>
</dd></dl>
<dl class="function">
<dt id="sc.median">
<code class="descname">median</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the median of the arguments, i.e. the value dividing the set of arguments into two evenly sized parts.</p>
<p>First the set of arguments is sorted. If the number of arguments is odd, the element in the middle of the sorted list is returned. If the number of arguments is even, the arithmetic mean of the two central elements is returned.</p>
</dd></dl>
<dl class="function">
<dt id="sc.min">
<code class="descname">min</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Returns the minimum out of the supplied argument list. The arguments must be real and share the same dimension.</p>
</dd></dl>
<dl class="function">
<dt id="sc.max">
<code class="descname">max</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Returns the maximum out of the supplied argument list. The arguments must be real and share the same dimension.</p>
</dd></dl>
<dl class="function">
<dt id="sc.sum">
<code class="descname">sum</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the sum of all the given arguments. These must share the same dimension.</p>
</dd></dl>
<dl class="function">
<dt id="sc.product">
<code class="descname">product</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the product of all the given arguments.</p>
</dd></dl>
<dl class="function">
<dt id="sc.variance">
<code class="descname">variance</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the population variance of the arguments. The variance is measure for the spreading of a set of numbers.</p>
<p>The arguments must share the same dimension.</p>
<table class="-x-quark-box -x-quark-admonition -x-quark-note"><tbody><tr><td width="100%" class="-x-quark-box-td"><div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function computes the <em>population variance</em>, which assumes that all possible realizations are all given as arguments. A function to estimate the variance from a sample (<em>sample variance</em>) is not included with SpeedCrunch.</p>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.stddev">
<code class="descname">stddev</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the standard deviation of the given arguments. It is obtained by taking the square root of the <a class="reference internal" href="#sc.variance" title="variance"><code class="xref sc sc-func docutils literal"><span class="pre">variance</span></code></a> of its arguments.</p>
</dd></dl>
<dl class="function">
<dt id="sc.absdev">
<code class="descname">absdev</code><span class="sig-paren">(</span><em>x1</em>; <em>x2</em>; <em>...</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the average absolute deviation of the arguments from their mean. This means that, with <code class="docutils literal"><span class="pre">x</span> <span class="pre">=</span> <span class="pre">average(x1;</span> <span class="pre">x2;</span> <span class="pre">...)</span></code>, we have:</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">absdev</span><span class="p">(</span><span class="n">x1</span><span class="p">;</span> <span class="n">x2</span><span class="p">;</span> <span class="p">...</span> <span class="p">)</span> <span class="o">=</span> <span class="n">abs</span><span class="p">(</span><span class="n">x1</span> <span class="o">-</span> <span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">abs</span><span class="p">(</span><span class="n">x2</span> <span class="o">-</span> <span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="p">...</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
</div>
<div class="section" id="binomial-distribution">
<span id="id1"></span><h2>Binomial Distribution</h2>
<p>The binomial distribution is described by the parameters <code class="docutils literal"><span class="pre">N</span></code> and <code class="docutils literal"><span class="pre">p</span></code>. It gives the probability distribution of the number of successful trials, when the total number of trials is given by <code class="docutils literal"><span class="pre">N</span></code>, and each test is successful with probability <code class="docutils literal"><span class="pre">p</span></code>. Not that unlike the <a class="reference internal" href="#hypergeometric-distribution"><span class="std std-ref">Hypergeometric Distribution</span></a>, the probability <code class="docutils literal"><span class="pre">p</span></code> remains the same for all draws. The binomial distribution can be thought of drawing <em>with</em> replacement, while the hypergeometric distribution describes drawing <em>without</em> replacement.</p>
<dl class="function">
<dt id="sc.binomcdf">
<code class="descname">binomcdf</code><span class="sig-paren">(</span><em>x</em>; <em>N</em>; <em>p</em><span class="sig-paren">)</span></dt>
<dd><p>Binomial cumulative distribution function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – maximum number of successes, must be integer</li>
<li><strong>N</strong> – number of trials, must be a positive integer</li>
<li><strong>p</strong> – probability to succeed a single trial, <em>0 <= p <= 1</em></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The function computes the probability, that, for <code class="docutils literal"><span class="pre">N</span></code> independent repetitions of a test successful with probability <code class="docutils literal"><span class="pre">p</span></code> each, the total number of successes is <strong>less than or equal</strong> to <code class="docutils literal"><span class="pre">x</span></code>.</p>
<p>Example: When tossing a fair coin 9 times, what is the probability that we find Heads at most 5 times?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">binomcdf</span><span class="p">(</span><span class="mi">5</span><span class="p">;</span> <span class="mi">9</span><span class="p">;</span> <span class="mf">0.5</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.74609375</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.binompmf">
<code class="descname">binompmf</code><span class="sig-paren">(</span><em>x</em>; <em>N</em>; <em>p</em><span class="sig-paren">)</span></dt>
<dd><p>Binomial probability mass function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – maximum number of successes, must be integer</li>
<li><strong>N</strong> – number of trials, must be a positive integer</li>
<li><strong>p</strong> – probability to succeed a single trial, <em>0 <= p <= 1</em></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The function computes the probability, that, for <code class="docutils literal"><span class="pre">N</span></code> independent repetitions of a test, each successful with probability <code class="docutils literal"><span class="pre">p</span></code>, the total number of successes is <strong>exactly equal</strong> to <code class="docutils literal"><span class="pre">x</span></code>.</p>
<p>Example: When tossing a fair coin 9 times, what is the probability that we find Heads exactly 5 times?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">binompmf</span><span class="p">(</span><span class="mi">5</span><span class="p">;</span> <span class="mi">9</span><span class="p">;</span> <span class="mf">0.5</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.24609375</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.binommean">
<code class="descname">binommean</code><span class="sig-paren">(</span><em>N</em>; <em>p</em><span class="sig-paren">)</span></dt>
<dd><p>Mean (expectation) value of the given binomial distribution.</p>
<p>The function computes the expected number of successes when an experiment is performed <code class="docutils literal"><span class="pre">N</span></code> times, each successful independently with probability <code class="docutils literal"><span class="pre">p</span></code>. The result will simply be given by <em>N * p</em>.</p>
</dd></dl>
<dl class="function">
<dt id="sc.binomvar">
<code class="descname">binomvar</code><span class="sig-paren">(</span><em>N</em>; <em>p</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the variance of the given binomial distribution function, equal to <em>N * p * (1-p)</em>.</p>
</dd></dl>
<dl class="function">
<dt id="sc.ncr">
<code class="descname">ncr</code><span class="sig-paren">(</span><em>N</em>; <em>k</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the binomial coefficient, equal to the number of possibilities of how to select <code class="docutils literal"><span class="pre">k</span></code> elements from a set of size <code class="docutils literal"><span class="pre">N</span></code>. The order of the <code class="docutils literal"><span class="pre">k</span></code> elements is of no importance, i.e. permutations of a subset are not counted as an additional choice.</p>
<p>In SpeedCrunch the domain of <a class="reference internal" href="#sc.ncr" title="ncr"><code class="xref sc sc-func docutils literal"><span class="pre">ncr()</span></code></a> is extended to all real numbers. The result is <em>1/((N + 1) * B(k + 1, N - k + 1))</em>, where <em>B(a, b)</em> is the complete Beta function.</p>
</dd></dl>
<dl class="function">
<dt id="sc.npr">
<code class="descname">npr</code><span class="sig-paren">(</span><em>N</em>; <em>k</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the binomial coefficient, equal to the number of possibilities of how to select <code class="docutils literal"><span class="pre">k</span></code> elements from a set of size <code class="docutils literal"><span class="pre">N</span></code>. The order of the <code class="docutils literal"><span class="pre">k</span></code> elements <strong>is</strong> important, i.e. permutations of a subset are counted as an additional choice.</p>
<p>In SpeedCrunch, the domain of <a class="reference internal" href="#sc.npr" title="npr"><code class="xref sc sc-func docutils literal"><span class="pre">npr()</span></code></a> is extended to all real numbers. The result is <em>Γ(N + 1)/Γ(k)</em>, where <em>Γ</em> is the gamma function; see <a class="reference internal" href="basic.html#sc.gamma" title="gamma"><code class="xref sc sc-func docutils literal"><span class="pre">gamma()</span></code></a>.</p>
</dd></dl>
</div>
<div class="section" id="hypergeometric-distribution">
<span id="id2"></span><h2>Hypergeometric Distribution</h2>
<p>The hypergeometric distribution is described by the three parameters <code class="docutils literal"><span class="pre">N</span></code>, <code class="docutils literal"><span class="pre">K</span></code> and <code class="docutils literal"><span class="pre">n</span></code>. It describes the probability distribution of the number of successes when drawing <code class="docutils literal"><span class="pre">n</span></code> samples from a finite population of size <code class="docutils literal"><span class="pre">N</span></code>, containing exactly <code class="docutils literal"><span class="pre">K</span></code> successes. Unlike the <a class="reference internal" href="#binomial-distribution"><span class="std std-ref">Binomial Distribution</span></a>, the hypergeometric distribution describes drawing <em>without</em> replacement.</p>
<dl class="function">
<dt id="sc.hyperpmf">
<code class="descname">hyperpmf</code><span class="sig-paren">(</span><em>k</em>; <em>N</em>; <em>K</em>; <em>n</em><span class="sig-paren">)</span></dt>
<dd><p>Hypergeometric probability mass function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>k</strong> – desired number of successes, must be integer</li>
<li><strong>N</strong> – total size of the population, must be positive integer</li>
<li><strong>K</strong> – number of successes within the population, <em>0 <= K <= N</em>, must be integer</li>
<li><strong>n</strong> – number of draws, <em>0 <= n <= N</em>, must be integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The function computes the probability that for <code class="docutils literal"><span class="pre">n</span></code> draws without replacement from a population of size <code class="docutils literal"><span class="pre">N</span></code> and containing <code class="docutils literal"><span class="pre">K</span></code> successes, the number of successes drawn is <em>exactly</em> equal to <code class="docutils literal"><span class="pre">k</span></code>.</p>
<p>Example: An urn contains 50 marbles, 40 of which are white, the rest are black. We draw 15 marbles without replacement. What is the probability of drawing 8 white ones?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">hyperpmf</span><span class="p">(</span><span class="mi">8</span><span class="p">;</span> <span class="mi">50</span><span class="p">;</span> <span class="mi">40</span><span class="p">;</span> <span class="mi">15</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.00410007</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.hypercdf">
<code class="descname">hypercdf</code><span class="sig-paren">(</span><em>k</em>; <em>N</em>; <em>K</em>; <em>n</em><span class="sig-paren">)</span></dt>
<dd><p>Hypergeometric cumulative distribution function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>k</strong> – maximum desired number of successes, must be integer</li>
<li><strong>N</strong> – total size of the population, must be positive integer</li>
<li><strong>K</strong> – number of successes within the population, <em>0 <= K <= N</em>, must be integer</li>
<li><strong>n</strong> – number of draws, <em>0 <= n <= N</em>, must be integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>The function computes the probability that for <code class="docutils literal"><span class="pre">n</span></code> draws without replacement from a population of size <code class="docutils literal"><span class="pre">N</span></code> and containing <code class="docutils literal"><span class="pre">K</span></code> successes, the number of successes drawn is <em>smaller than or equal</em> to <code class="docutils literal"><span class="pre">k</span></code>.</p>
<p>Example: An urn contains 50 marbles, 40 of which are white, the rest are black. We draw 15 marbles without replacement. What is the probability of drawing at most 8 white ones?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">hypercdf</span><span class="p">(</span><span class="mi">8</span><span class="p">;</span> <span class="mi">50</span><span class="p">;</span> <span class="mi">40</span><span class="p">;</span> <span class="mi">15</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.00449015</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.hypermean">
<code class="descname">hypermean</code><span class="sig-paren">(</span><em>N</em>; <em>k</em>; <em>n</em><span class="sig-paren">)</span></dt>
<dd><p>Expected value of the given hypergeometric distribution.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>N</strong> – total size of the population, must be positive integer</li>
<li><strong>K</strong> – number of successes within the population, <em>0 <= K <= N</em>, must be integer</li>
<li><strong>n</strong> – number of draws, <em>0 <= n <= N</em>, must be integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Example: An urn contains 50 marbles, 40 of which are white, the rest are black. We draw 15 marbles without replacement. How many white marbles do we expect to find in our drawn sample?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">hypermean</span><span class="p">(</span><span class="mi">50</span><span class="p">;</span> <span class="mi">40</span><span class="p">;</span> <span class="mi">15</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 12</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.hypervar">
<code class="descname">hypervar</code><span class="sig-paren">(</span><em>N</em>; <em>k</em>; <em>n</em><span class="sig-paren">)</span></dt>
<dd><p>Variance of the given hypergeometric distribution.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>N</strong> – total size of the population, must be positive integer</li>
<li><strong>K</strong> – number of successes within the population, <em>0 <= K <= N</em>, must be integer</li>
<li><strong>n</strong> – number of draws, <em>0 <= n <= N</em>, must be integer</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Example: An urn contains 50 marbles, 40 of which are white, the rest are black. We draw 15 marbles without replacement. We estimate the standard deviation of the experiment:</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">sqrt</span><span class="p">(</span><span class="n">hypervar</span><span class="p">(</span><span class="mi">50</span><span class="p">;</span> <span class="mi">40</span><span class="p">;</span> <span class="mi">15</span><span class="p">))</span><span class="ge"></span>
<span class="ge">= 1.309</span>
</pre></div>
</div>
</td></tr></tbody></table><p>This number is an estimate on by how many marbles our sample will deviate from the expectation value.</p>
</dd></dl>
</div>
<div class="section" id="poisson-distribution">
<h2>Poisson Distribution</h2>
<p>The Poisson distribution is characterized by only a single parameter, named <code class="docutils literal"><span class="pre">mu</span></code>. It represents both the mean and the variance of the distribution. It describes the probability distribution of the number of events during a fixed period of time, when the average rate of events is known. The Poisson distribution requires the events to be independent. This is usually a good approximation when the rate is low compared to the total population size.</p>
<dl class="function">
<dt id="sc.poipmf">
<code class="descname">poipmf</code><span class="sig-paren">(</span><em>x</em>; <em>mu</em><span class="sig-paren">)</span></dt>
<dd><p>Poisson probability mass function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – Desired number of events, must be integer</li>
<li><strong>mu</strong> – Average number of events, must be positive</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Computes the probability to observe exactly <code class="docutils literal"><span class="pre">x</span></code> events.</p>
<p><em>Example 1</em>: In a manufacturing process with yield of 99%, what is the probability that 2 out of 10 manufactured products are failures?
First, we note that according to the yield, the expected number of failures are given by:</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="mi">10 </span><span class="o">*</span> <span class="p">(</span><span class="mi">1</span><span class="o">-</span><span class="mf">0.99</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.1</span>
</pre></div>
</div>
</td></tr></tbody></table><p>Hence the answer to the problem is:</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">poipmf</span><span class="p">(</span><span class="mi">2</span><span class="p">;</span> <span class="mf">0.1</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.0045</span>
</pre></div>
</div>
</td></tr></tbody></table><p><em>Example 2</em> ::An insurance company expects 10 claims over the period of one year. What is the probability that instead as many as 20 claims will be filed?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="n">poipmf</span><span class="p">(</span><span class="mi">20</span><span class="p">;</span> <span class="mi">10</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.001866</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.poicdf">
<code class="descname">poicdf</code><span class="sig-paren">(</span><em>x</em>; <em>mu</em><span class="sig-paren">)</span></dt>
<dd><p>Poisson cumulative distribution function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>x</strong> – Desired number of events, must be integer</li>
<li><strong>mu</strong> – Average number of events, must be positive</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Computes the probability to observe <code class="docutils literal"><span class="pre">x</span></code> or fewer events.</p>
<p>Example: An insurance company expects 10 claims over the period of one year. What is the probability that more than 12 claims will be filed?</p>
<table class="-x-quark-literal-block"><tbody><tr><td width="100%" class="-x-quark-literal-block-td"><div class="highlight-speedcrunch"><div class="highlight"><pre><span class="mi">1 </span><span class="o">-</span> <span class="n">poicdf</span><span class="p">(</span><span class="mi">12</span><span class="p">;</span> <span class="mi">10</span><span class="p">)</span><span class="ge"></span>
<span class="ge">= 0.208</span>
</pre></div>
</div>
</td></tr></tbody></table></dd></dl>
<dl class="function">
<dt id="sc.poimean">
<code class="descname">poimean</code><span class="sig-paren">(</span><em>mu</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the expectation value of the given Poisson distribution. By definition, this value is equal to <code class="docutils literal"><span class="pre">mu</span></code>.</p>
</dd></dl>
<dl class="function">
<dt id="sc.poivar">
<code class="descname">poivar</code><span class="sig-paren">(</span><em>mu</em><span class="sig-paren">)</span></dt>
<dd><p>Computes the variance of the given Poisson distribution. By definition, this value is equal to <code class="docutils literal"><span class="pre">mu</span></code>.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<table class="navbar navbar-bottom">
<tr>
<td width="50%">
<a class="nav-item nav-item-0"
href="../contents.html">SpeedCrunch 0.12 documentation</a> » <a class="nav-item nav-item-1"
href="index.html">Reference</a>
</td>
<td align="right" width="50%">
<a class="rel-item rel-item-1"
href="integer.html"
title="Integer & Bitwise Arithmetic Functions"
>previous</a>
|
<a class="rel-item rel-item-2"
href="ieee754.html"
title="IEEE-754 Functions"
>next</a>
|
<a class="rel-item rel-item-3"
href="../sc-functionindex.html"
title="Function Index"
>functions</a>
|
<a class="rel-item rel-item-4"
href="../genindex.html"
title="General Index"
>index</a>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<div class="footer" role="contentinfo">
© Copyright 2016, The SpeedCrunch Developers.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
</div>
</td>
</tr>
</table>
</body>
</html>
|