-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprobability.html
More file actions
178 lines (137 loc) · 9.24 KB
/
probability.html
File metadata and controls
178 lines (137 loc) · 9.24 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>tyche.probability — Tyche v1.0.1 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="tyche.references" href="references.html" />
<link rel="prev" title="tyche.distributions" href="distributions.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-tyche.probability">
<span id="tyche-probability"></span><h1>tyche.probability<a class="headerlink" href="#module-tyche.probability" title="Permalink to this heading">¶</a></h1>
<p>This module contains probability calculations that are
used in many places in Tyche.</p>
<dl class="py exception">
<dt class="sig sig-object py" id="tyche.probability.TycheProbabilityException">
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">tyche.probability.</span></span><span class="sig-name descname"><span class="pre">TycheProbabilityException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tyche/probability.html#TycheProbabilityException"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tyche.probability.TycheProbabilityException" title="Permalink to this definition">¶</a></dt>
<dd><p>An exception type that is thrown when errors occur in
the use of the probability methods in this module.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>message</strong> (<em>str</em>) – </p>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tyche.probability.random_probability">
<span class="sig-prename descclassname"><span class="pre">tyche.probability.</span></span><span class="sig-name descname"><span class="pre">random_probability</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rng</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tyche/probability.html#random_probability"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tyche.probability.random_probability" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a random probability from the range [0, 1].</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>rng</strong> (<em>Generator</em>) – </p></li>
<li><p><strong>shape</strong> (<em>Optional</em><em>[</em><em>Union</em><em>[</em><em>int</em><em>, </em><em>tuple</em><em>]</em><em>]</em>) – </p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="tyche.probability.uncertain_bayes_rule">
<span class="sig-prename descclassname"><span class="pre">tyche.probability.</span></span><span class="sig-name descname"><span class="pre">uncertain_bayes_rule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prob_concept</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prob_obs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prob_obs_given_concept</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">likelihood</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/tyche/probability.html#uncertain_bayes_rule"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tyche.probability.uncertain_bayes_rule" title="Permalink to this definition">¶</a></dt>
<dd><p>Bayes’ rule for uncertain observations.</p>
<p>Let A be a concept, and B be an observation with a phi=likelihood chance of being true.
P(A|B) = phi * P(B|A) * P(A) / P(B) + (1 - phi) * (1 - P(B|A)) * P(A) / (1 - P(B))</p>
<p>To avoid division by zero, the following special cases are also used:
- If likelihood is 0, then P(A|B) = (1 - likelihood) * (1 - P(B|A)) * P(A) / (1 - P(B))
- If likelihood is 1, then P(A|B) = likelihood * P(B|A) * P(A) / P(B)</p>
<p>The rules for this were derived by applying bayes rule to the event that the observation occurred
or was incorrectly observed ((event with likelihood) OR (NOT event with 1 - likelihood)).
Therefore, a likelihood of 0 represents that the observation was observed to be false
(this is equivalent to observing NOT observation).
See: <a class="reference external" href="https://stats.stackexchange.com/questions/345200/applying-bayess-theorem-when-evidence-is-uncertain">https://stats.stackexchange.com/questions/345200/applying-bayess-theorem-when-evidence-is-uncertain</a></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>prob_concept</strong> (<em>float</em>) – </p></li>
<li><p><strong>prob_obs</strong> (<em>float</em>) – </p></li>
<li><p><strong>prob_obs_given_concept</strong> (<em>float</em>) – </p></li>
<li><p><strong>likelihood</strong> (<em>float</em>) – </p></li>
</ul>
</dd>
</dl>
</dd></dl>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/logo.png" alt="Logo"/>
</a></p>
<h1 class="logo"><a href="index.html">Tyche</a></h1>
<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="language.html">tyche.language</a></li>
<li class="toctree-l1"><a class="reference internal" href="individuals.html">tyche.individuals</a></li>
<li class="toctree-l1"><a class="reference internal" href="distributions.html">tyche.distributions</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">tyche.probability</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#tyche.probability.TycheProbabilityException">TycheProbabilityException</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tyche.probability.random_probability">random_probability</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tyche.probability.uncertain_bayes_rule">uncertain_bayes_rule</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="references.html">tyche.references</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="distributions.html" title="previous chapter">tyche.distributions</a></li>
<li>Next: <a href="references.html" title="next chapter">tyche.references</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2023, Padraig Lamont, drtnf.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 5.1.1</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
|
<a href="_sources/probability.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>