-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.html
337 lines (321 loc) · 28.5 KB
/
tools.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>4. Tools — pypmc 1.1.4 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="3. Mixture adaptation" href="mix_adapt.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="mix_adapt.html" title="3. Mixture adaptation"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">pypmc 1.1.4 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">4. </span>Tools</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-pypmc.tools">
<span id="tools"></span><h1><span class="section-number">4. </span>Tools<a class="headerlink" href="#module-pypmc.tools" title="Permalink to this headline">¶</a></h1>
<p>Helper functions for general purposes</p>
<div class="section" id="module-pypmc.tools.convergence">
<span id="convergence-diagnostics"></span><h2><span class="section-number">4.1. </span>Convergence diagnostics<a class="headerlink" href="#module-pypmc.tools.convergence" title="Permalink to this headline">¶</a></h2>
<p>Provide functions to rate the quality of weighted samples.</p>
</div>
<div class="section" id="history">
<h2><span class="section-number">4.2. </span>History<a class="headerlink" href="#history" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="pypmc.tools.History">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">pypmc.tools.</span></code><code class="sig-name descname"><span class="pre">History</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prealloc</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/_history.html#History"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.History" title="Permalink to this definition">¶</a></dt>
<dd><p>Save a history of 1d-arrays.
Each call to <code class="xref py py-meth docutils literal notranslate"><span class="pre">append</span></code> is counted as a new “run”.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dim</strong> – Integer; the length of 1d-arrays to be saved.</p></li>
<li><p><strong>prealloc</strong> – Integer; indicates for how many points memory is allocated in advance.
When more memory is needed, it will be allocated on demand.</p></li>
</ul>
</dd>
</dl>
<p>Access:</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">self[run_nr]</span></code> and <code class="docutils literal notranslate"><span class="pre">self[run_begin:run_end]</span></code> return <em>one</em> array
that includes the samples for the runs specified (excluding run_end).</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Index access returns a reference. Modification changes the history.</p>
</div>
<div class="admonition hint">
<p class="admonition-title">Hint</p>
<p>Negative numbers are supported, for example <code class="docutils literal notranslate"><span class="pre">self[-1]</span></code> returns
the latest run.</p>
</div>
</div></blockquote>
<dl>
<dt>Example:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">h</span> <span class="o">=</span> <span class="n">History</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">):</span>
<span class="gp">>>> </span> <span class="n">a</span> <span class="o">=</span> <span class="n">h</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">>>> </span> <span class="n">a</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">i</span><span class="o">+</span><span class="mi">1</span>
<span class="gp">>>> </span><span class="n">h</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="c1"># first run</span>
<span class="go">array([[ 1., 1.]])</span>
<span class="gp">>>> </span><span class="n">h</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="c1"># second run</span>
<span class="go">array([[ 2., 2.],</span>
<span class="go"> [ 2., 2.]])</span>
<span class="gp">>>> </span><span class="n">h</span><span class="p">[:]</span> <span class="c1"># entire history</span>
<span class="go">array([[ 1., 1.],</span>
<span class="go"> [ 2., 2.],</span>
<span class="go"> [ 2., 2.]])</span>
<span class="gp">>>> </span><span class="nb">len</span><span class="p">(</span><span class="n">h</span><span class="p">)</span> <span class="c1"># number of runs</span>
<span class="go">2</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="module-pypmc.tools.indicator">
<span id="indicator"></span><h2><span class="section-number">4.3. </span>Indicator<a class="headerlink" href="#module-pypmc.tools.indicator" title="Permalink to this headline">¶</a></h2>
<p>Collect generators of typical indicator functions.</p>
<dl class="py function">
<dt id="pypmc.tools.indicator.ball">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.indicator.</span></code><code class="sig-name descname"><span class="pre">ball</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">center</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">radius</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bdy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/indicator/_indicator_factory.html#ball"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.indicator.ball" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the indicator function of a ball.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>center</strong> – <p>A vector-like numpy array, defining the center of the ball.</p>
<p>len(center) fixes the dimension.</p>
</p></li>
<li><p><strong>radius</strong> – Float or int, the radius of the ball</p></li>
<li><p><strong>bdy</strong> – Bool, When <code class="docutils literal notranslate"><span class="pre">x</span></code> is at the ball’s boundary then
<code class="docutils literal notranslate"><span class="pre">ball_indicator(x)</span></code> returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if and only if
<code class="docutils literal notranslate"><span class="pre">bdy=True</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="pypmc.tools.indicator.hyperrectangle">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.indicator.</span></code><code class="sig-name descname"><span class="pre">hyperrectangle</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">lower</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">upper</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bdy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/indicator/_indicator_factory.html#hyperrectangle"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.indicator.hyperrectangle" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the indicator function of a hyperrectangle.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>lower</strong> – <p>Vector-like numpy array, defining the lower boundary of the hyperrectangle.</p>
<p>len(lower) fixes the dimension.</p>
</p></li>
<li><p><strong>upper</strong> – Vector-like numpy array, defining the upper boundary of the hyperrectangle.</p></li>
<li><p><strong>bdy</strong> – Bool. When <code class="docutils literal notranslate"><span class="pre">x</span></code> is at the hyperrectangles’s boundary then
<code class="docutils literal notranslate"><span class="pre">hr_indicator(x)</span></code> returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if and only if <code class="docutils literal notranslate"><span class="pre">bdy=True</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="pypmc.tools.indicator.merge_function_with_indicator">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.indicator.</span></code><code class="sig-name descname"><span class="pre">merge_function_with_indicator</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">indicator</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alternative</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/indicator/_indicator_merge.html#merge_function_with_indicator"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.indicator.merge_function_with_indicator" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a function such that a call to it is equivalent to:</p>
<dl class="simple">
<dt>if indicator(x):</dt><dd><p>return function(x)</p>
</dd>
<dt>else:</dt><dd><p>return alternative</p>
</dd>
</dl>
<p>Note that <code class="docutils literal notranslate"><span class="pre">function</span></code> is not called if indicator evaluates to False.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>function</strong> – The function to be called when indicator returns True.</p></li>
<li><p><strong>indicator</strong> – Bool-returning function; the indicator</p></li>
<li><p><strong>alternative</strong> – The object to be returned when indicator returns False</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="module-pypmc.tools.parallel_sampler">
<span id="parallel-sampler"></span><h2><span class="section-number">4.4. </span>Parallel sampler<a class="headerlink" href="#module-pypmc.tools.parallel_sampler" title="Permalink to this headline">¶</a></h2>
<p>Run sampling algorithms in parallel using mpi4py</p>
<dl class="py class">
<dt id="pypmc.tools.parallel_sampler.MPISampler">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">pypmc.tools.parallel_sampler.</span></code><code class="sig-name descname"><span class="pre">MPISampler</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sampler_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">comm</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">MPI.COMM_WORLD</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mpi_tag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/parallel_sampler.html#MPISampler"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.parallel_sampler.MPISampler" title="Permalink to this definition">¶</a></dt>
<dd><p>An MPI4Py parallelized sampler. Parallelizes any <a class="reference internal" href="sampler.html#module-pypmc.sampler" title="pypmc.sampler"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pypmc.sampler</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sampler_type</strong> – A class defined in <a class="reference internal" href="sampler.html#module-pypmc.sampler" title="pypmc.sampler"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pypmc.sampler</span></code></a>; the class of the
sampler to be run in parallel. Example: <code class="docutils literal notranslate"><span class="pre">sampler_type=ImportanceSampler</span></code>.</p></li>
<li><p><strong>comm</strong> – <code class="docutils literal notranslate"><span class="pre">mpi4py</span></code> communicator; the communicator to be used.</p></li>
<li><p><strong>kwargs</strong> (<em>args</em><em>,</em>) – Additional arguments which are passed to the constructor of
<code class="docutils literal notranslate"><span class="pre">sampler_type</span></code>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="partition">
<h2><span class="section-number">4.5. </span>Partition<a class="headerlink" href="#partition" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="pypmc.tools.partition">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.</span></code><code class="sig-name descname"><span class="pre">partition</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">N</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/_partition.html#partition"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.partition" title="Permalink to this definition">¶</a></dt>
<dd><p>Distribute <code class="docutils literal notranslate"><span class="pre">N</span></code> into <code class="docutils literal notranslate"><span class="pre">k</span></code> parts such that each part
takes the value <code class="docutils literal notranslate"><span class="pre">N//k</span></code> or <code class="docutils literal notranslate"><span class="pre">N//k</span> <span class="pre">+</span> <span class="pre">1</span></code> where <code class="docutils literal notranslate"><span class="pre">//</span></code> denotes integer
division; i.e., perform the minimal lexicographic integer partition.</p>
<p>Example: N = 5, k = 2 –> return [3, 2]</p>
</dd></dl>
<dl class="py function">
<dt id="pypmc.tools.patch_data">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.</span></code><code class="sig-name descname"><span class="pre">patch_data</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">L</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">try_diag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/_partition.html#patch_data"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.patch_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Patch <code class="docutils literal notranslate"><span class="pre">data</span></code> (for example Markov chain output) into parts of
length <code class="docutils literal notranslate"><span class="pre">L</span></code>. Return a Gaussian mixture where each component gets
the empirical mean and covariance of one patch.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> – Matrix-like array; the points to be patched. Expect <code class="docutils literal notranslate"><span class="pre">data[i]</span></code>
as the d-dimensional i-th point.</p></li>
<li><p><strong>L</strong> – Integer; the length of one patch. The last patch will be shorter
if <code class="docutils literal notranslate"><span class="pre">L</span></code> is not a divisor of <code class="docutils literal notranslate"><span class="pre">len(data)</span></code>.</p></li>
<li><p><strong>try_diag</strong> – Bool; If some patch does not define a proper covariance matrix,
it cannot define a Gaussian component. <code class="docutils literal notranslate"><span class="pre">try_diag</span></code> defines how
to handle that case:
If <code class="docutils literal notranslate"><span class="pre">True</span></code> (default), the off-diagonal elements are set to zero
and it is tried to form a Gaussian with that matrix again. If
that fails as well, the patch is skipped.
If <code class="docutils literal notranslate"><span class="pre">False</span></code> the patch is skipped directly.</p></li>
<li><p><strong>verbose</strong> – Bool; If <code class="docutils literal notranslate"><span class="pre">True</span></code> print all status information.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="plot">
<h2><span class="section-number">4.6. </span>Plot<a class="headerlink" href="#plot" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="pypmc.tools.plot_mixture">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.</span></code><code class="sig-name descname"><span class="pre">plot_mixture</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mixture</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">i</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">j</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">center_style</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{'s':</span> <span class="pre">0.15}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'nipy_spectral'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cutoff</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ellipse_style</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{'alpha':</span> <span class="pre">0.3}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solid_edge</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">visualize_weights</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/_plot.html#plot_mixture"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.plot_mixture" title="Permalink to this definition">¶</a></dt>
<dd><p>Plot the (Gaussian) components of the <code class="docutils literal notranslate"><span class="pre">mixture</span></code> density as
one-sigma ellipses in the <code class="docutils literal notranslate"><span class="pre">(i,j)</span></code> plane.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>center_style</strong> – If a non-empty <code class="docutils literal notranslate"><span class="pre">dict</span></code>, plot mean value with the style passed to <code class="docutils literal notranslate"><span class="pre">scatter</span></code>.</p></li>
<li><p><strong>cmap</strong> – The color map to which components are mapped in order to
choose their face color. It is unaffected by the
<code class="docutils literal notranslate"><span class="pre">cutoff</span></code>. The meaning depends on <code class="docutils literal notranslate"><span class="pre">visualize_weights</span></code>.</p></li>
<li><p><strong>cutoff</strong> – Ignore components whose weight is below the <code class="docutils literal notranslate"><span class="pre">cut</span> <span class="pre">off</span></code>.</p></li>
<li><p><strong>ellipse_style</strong> – Passed on to define the properties of the <code class="docutils literal notranslate"><span class="pre">Ellipse</span></code>.</p></li>
<li><p><strong>solid_edge</strong> – Draw the edge of the ellipse as solid opaque line.</p></li>
<li><p><strong>visualize_weights</strong> – Colorize the components according to their weights if <code class="docutils literal notranslate"><span class="pre">True</span></code>.
One can do <cite>plt.colorbar()</cite> after this function and the bar allows to read off the weights.
If <code class="docutils literal notranslate"><span class="pre">False</span></code>, coloring is based on the component index and the total number of components.
This option makes it easier to track components by assigning them the same color in subsequent calls to this function.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="pypmc.tools.plot_responsibility">
<code class="sig-prename descclassname"><span class="pre">pypmc.tools.</span></code><code class="sig-name descname"><span class="pre">plot_responsibility</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">responsibility</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cmap</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'nipy_spectral'</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypmc/tools/_plot.html#plot_responsibility"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pypmc.tools.plot_responsibility" title="Permalink to this definition">¶</a></dt>
<dd><p>Classify the 2D <code class="docutils literal notranslate"><span class="pre">data</span></code> according to the <code class="docutils literal notranslate"><span class="pre">responsibility</span></code> and
make a scatter plot of each data point with the color of the
component it is most likely from. The <code class="docutils literal notranslate"><span class="pre">responsibility</span></code> is
normalized internally such that each row sums to unity.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> – matrix-like; one row = one 2D sample</p></li>
<li><p><strong>responsibility</strong> – matrix-like; one row = probabilities that sample n is from
1st, 2nd, … component. The number of rows has to agree with <code class="docutils literal notranslate"><span class="pre">data</span></code></p></li>
<li><p><strong>cmap</strong> – colormap; defines how component indices are mapped to the
color of the data points</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">4. Tools</a><ul>
<li><a class="reference internal" href="#module-pypmc.tools.convergence">4.1. Convergence diagnostics</a></li>
<li><a class="reference internal" href="#history">4.2. History</a></li>
<li><a class="reference internal" href="#module-pypmc.tools.indicator">4.3. Indicator</a></li>
<li><a class="reference internal" href="#module-pypmc.tools.parallel_sampler">4.4. Parallel sampler</a></li>
<li><a class="reference internal" href="#partition">4.5. Partition</a></li>
<li><a class="reference internal" href="#plot">4.6. Plot</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="mix_adapt.html"
title="previous chapter"><span class="section-number">3. </span>Mixture adaptation</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/tools.rst.txt"
rel="nofollow">Show Source</a></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" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="mix_adapt.html" title="3. Mixture adaptation"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">pypmc 1.1.4 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href=""><span class="section-number">4. </span>Tools</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2019, Frederik Beaujean and Stephan Jahn.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.5.2.
</div>
</body>
</html>