-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
457 lines (412 loc) · 23.7 KB
/
index.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
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
457
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="None">
<meta name="author" content="Hakaru Team">
<link rel="shortcut icon" href="img/favicon.ico">
<title>Hakaru</title>
<link href="css/bootstrap-custom.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/base.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/color-brewer.min.css">
<link href="logo.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="js/jquery-1.10.2.min.js" defer></script>
<script src="js/bootstrap-3.0.3.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body class="homepage">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=".">Hakaru</a>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li class="active">
<a href=".">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Introduction <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="intro/probprog/">What is Probabilistic Programming?</a>
</li>
<li >
<a href="intro/installation/">Installing Hakaru</a>
</li>
<li >
<a href="intro/samplegen/">Generating Samples from your Hakaru Program</a>
</li>
<li >
<a href="intro/quickstart/">Quick Start: A Mixture Model Example</a>
</li>
<li >
<a href="transforms/compile/">Compiling to Haskell</a>
</li>
<li >
<a href="transforms/hkc/">Compiling to C</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Workflow and Examples <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="workflow/intro/">What is the Hakaru Workflow?</a>
</li>
<li >
<a href="workflow/discrete/">Tutorial: Hakaru Workflow for Discrete Models</a>
</li>
<li >
<a href="workflow/continuous/">Tutorial: Hakaru Workflow for Continuous Models</a>
</li>
<li >
<a href="examples/">Examples</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Language Guide <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="lang/rand/">Primitive Probability Distributions</a>
</li>
<li >
<a href="lang/letbind/">Let and Bind</a>
</li>
<li >
<a href="lang/cond/">Conditionals</a>
</li>
<li >
<a href="lang/functions/">Functions</a>
</li>
<li >
<a href="lang/coercions/">Types and Coercions</a>
</li>
<li >
<a href="lang/datatypes/">Data Types and Match</a>
</li>
<li >
<a href="lang/arrays/">Arrays and Plate</a>
</li>
<li >
<a href="lang/loops/">Loops</a>
</li>
<li >
<a href="transforms/expect/">Expect</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Transformations <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="transforms/normalize/">Normalize</a>
</li>
<li >
<a href="transforms/disintegrate/">Disintegrate</a>
</li>
<li >
<a href="transforms/density/">Density</a>
</li>
<li >
<a href="transforms/hk-maple/">Hakaru Maple</a>
</li>
<li >
<a href="transforms/mh/">Metropolis Hastings</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Internals <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="internals/ast/">AST and Hakaru Datakind</a>
</li>
<li >
<a href="internals/abt/">ABT</a>
</li>
<li >
<a href="internals/datums/">Datums</a>
</li>
<li >
<a href="internals/coercions/">Coercions</a>
</li>
<li >
<a href="internals/transforms/">Transformaitons</a>
</li>
<li >
<a href="internals/testing/">Testing</a>
</li>
<li >
<a href="internals/newfeature/">Adding a Language Feature</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
<li class="disabled">
<a rel="next" >
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>
<li >
<a rel="prev" href="intro/probprog/">
Next <i class="fa fa-arrow-right"></i>
</a>
</li>
<li>
<a href="https://github.com/hakaru-dev/hakaru/edit/master/docs/index.md"><i class="fa fa-github"></i> Edit on GitHub</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
<ul class="nav bs-sidenav">
<li class="main active"><a href="#introduction">Introduction</a></li>
<li><a href="#what-is-probabilistic-programming">What is Probabilistic Programming?</a></li>
<li><a href="#installing-hakaru">Installing Hakaru</a></li>
<li><a href="#generating-samples-from-your-hakaru-program">Generating Samples from your Hakaru Program</a></li>
<li><a href="#quick-start-a-mixture-model-example">Quick Start: A Mixture Model Example</a></li>
<li><a href="#compiling-to-haskell">Compiling to Haskell</a></li>
<li><a href="#compiling-to-c">Compiling to C</a></li>
<li class="main "><a href="#hakaru-workflow-and-examples">Hakaru Workflow and Examples</a></li>
<li><a href="#what-is-the-hakaru-workflow">What is the Hakaru Workflow?</a></li>
<li><a href="#tutorial-hakaru-workflow-for-discrete-models">Tutorial: Hakaru Workflow for Discrete Models</a></li>
<li><a href="#tutorial-hakaru-workflow-for-continuous-models">Tutorial: Hakaru Workflow for Continuous Models</a></li>
<li><a href="#examples">Examples</a></li>
<li class="main "><a href="#language-guide">Language Guide</a></li>
<li><a href="#primitive-probability-distributions">Primitive Probability Distributions</a></li>
<li><a href="#let-and-bind">Let and Bind</a></li>
<li><a href="#conditionals">Conditionals</a></li>
<li><a href="#functions">Functions</a></li>
<li><a href="#types-and-coercions">Types and Coercions</a></li>
<li><a href="#data-types-and-match">Data Types and Match</a></li>
<li><a href="#arrays-and-plate">Arrays and Plate</a></li>
<li><a href="#loops">Loops</a></li>
<li class="main "><a href="#transformations">Transformations</a></li>
<li><a href="#expect">Expect</a></li>
<li><a href="#normalize">Normalize</a></li>
<li><a href="#disintegrate">Disintegrate</a></li>
<li><a href="#density">Density</a></li>
<li><a href="#hakaru-maple">Hakaru-Maple</a></li>
<li><a href="#metropolis-hastings">Metropolis Hastings</a></li>
<li class="main "><a href="#internals">Internals</a></li>
<li class="main "><a href="#citing-us">Citing Us</a></li>
</ul>
</div></div>
<div class="col-md-9" role="main">
<h1 class="logo">Hakaru</h1>
<hr />
<p>Hakaru is a simply-typed probabilistic programming language, designed for easy specification of probabilistic models and inference algorithms. This type of language is useful
for the development of machine learning algorithms and stochastic modeling. Hakaru enables the design of modular probabilistic inference programs by providing:</p>
<ul>
<li>A language for representing probabilistic distributions, queries, and inferences</li>
<li>Methods for transforming probabilistic information, such as conditional probability and probabilistic inference, using computer algebra</li>
</ul>
<p>This documentation provides information for installing and using Hakaru. Sample programs are included to demonstrate some of Hakaru’s functionality and Hakaru implementation
details are included to help guide future Hakaru developments and extensions.</p>
<p><strong>Warning: This code is alpha and experimental.</strong></p>
<p>Contact us at ppaml@indiana.edu if you have any questions or concerns.</p>
<h2 id="introduction">Introduction</h2>
<p>The Introduction presents probabilistic programming and illustrates how Hakaru can be used to solve and describe these types of problems, how to install Hakaru on your
machine, and some sample programs to get you started.</p>
<h3 id="what-is-probabilistic-programming"><a href="intro/probprog">What is Probabilistic Programming?</a></h3>
<p>Probabilistic programming systems allow us to write programs which describe probability distributions, and provide mechanisms to sample and condition the distributions
they represent on data. In this page, we give a sense of the sorts of problems Hakaru is great at solving, and how you would describe them in Hakaru.</p>
<h3 id="installing-hakaru"><a href="intro/installation">Installing Hakaru</a></h3>
<p>You can install Hakaru on Linux, OSX, and Windows and extend its functionality using MapleSoft’s Maple. </p>
<h3 id="generating-samples-from-your-hakaru-program"><a href="intro/samplegen">Generating Samples from your Hakaru Program</a></h3>
<p>You can use the <code>hakaru</code> command to generate samples from your probabilistic model.</p>
<h3 id="quick-start-a-mixture-model-example"><a href="intro/quickstart">Quick Start: A Mixture Model Example</a></h3>
<p>This page will introduce you to Hakaru’s basic functionality by creating a program to sample and condition a mixture model of a coin toss.</p>
<h3 id="compiling-to-haskell"><a href="/transforms/compile">Compiling to Haskell</a></h3>
<p>A Hakaru program can be ported into Haskell which can then be converted into machine code for other applications.</p>
<h3 id="compiling-to-c"><a href="/transforms/hkc">Compiling to C</a></h3>
<p>Depending on the scale, a Hakaru program might be resource-intensive to run. In these situations, you could port your Hakaru program to C using the <code>hkc</code> command to take
advantage of other tools such as OpenMP for parallel processing. </p>
<h2 id="hakaru-workflow-and-examples">Hakaru Workflow and Examples</h2>
<h3 id="what-is-the-hakaru-workflow"><a href="/workflow/intro.md">What is the Hakaru Workflow?</a></h3>
<p>Hakaru provides a language and tools to aid in each step of the Bayesian inference workflow.</p>
<h3 id="tutorial-hakaru-workflow-for-discrete-models"><a href="workflow/discrete/">Tutorial: Hakaru Workflow for Discrete Models</a></h3>
<p>This example of a burglary alarm demonstrates the workflow typically followed when creating Hakaru programs.</p>
<h3 id="tutorial-hakaru-workflow-for-continuous-models"><a href="workflow/continuous/">Tutorial: Hakaru Workflow for Continuous Models</a></h3>
<p>This example of a thermometer calibration demonstrates the workflow typically followed when creating Hakaru programs that involve
random real numbers in their description.</p>
<h3 id="examples"><a href="examples">Examples</a></h3>
<p>Two examples, a Gaussian Mixture Model and a Latent Dirichlet Allocation (LDA) topic model, highlight the types of problems that Hakaru is uniquely suited to help you solve.</p>
<h2 id="language-guide">Language Guide</h2>
<p>The Language Guide presents an overview of Hakaru’s language primitives and core functionality.</p>
<h3 id="primitive-probability-distributions"><a href="/lang/rand">Primitive Probability Distributions</a></h3>
<p>Common probability distributions, such as the normal distribution, are already encoded in Hakaru and are considered to be language primitives. This page provides usage
instructions for accessing the primitive distributions in your programs.</p>
<h3 id="let-and-bind"><a href="/lang/letbind">Let and Bind</a></h3>
<p>Let (<code>=</code>) and Bind (<code><~</code>) enable the use of variables in Hakaru programs, which is essential for extracting a value from a probability distribution.</p>
<h3 id="conditionals"><a href="/lang/cond">Conditionals</a></h3>
<p>Hakaru supports a restricted <code>if</code> expression for selections between two conditions.</p>
<h3 id="functions"><a href="/lang/functions">Functions</a></h3>
<p>Hakaru supports both named and anonymous function definitions.</p>
<h3 id="types-and-coercions"><a href="/lang/coercions">Types and Coercions</a></h3>
<p>Hakaru has basic types which can also be combined to make complex ones. To aid in the communication of information between Hakaru functions, coercions are defined to allow
conversions between compatible types.</p>
<h3 id="data-types-and-match"><a href="/lang/datatypes">Data Types and Match</a></h3>
<p>Hakaru supports some built-in data types from Haskell. The <code>match</code> function is used for deconstructing them to extract their elements and to reconstructing data back into
these data types.</p>
<h3 id="arrays-and-plate"><a href="/lang/arrays">Arrays and Plate</a></h3>
<p>Hakaru has special syntax for arrays, which is considered distinct from the other supported data types. A specialized array, <code>plate</code>, is used for describing measures over
arrays.</p>
<h3 id="loops"><a href="/lang/loops">Loops</a></h3>
<p>Hakaru loops are specialized to compute the summation or product of the elements in an array.</p>
<h2 id="transformations">Transformations</h2>
<p>Hakaru includes some inference algorithms that you can use to transform your probabilistic models into other forms to extract desireable information. Its inference
algorithms are implemented predominantly as program transformations.</p>
<p><strong>Note:</strong> By default, Hakaru assigns a weight to each generated sample. Typically a weight of one is used, but it is possible for the weights to vary between samples. This
might result in differing results from the original and transformed programs when summarizing a program’s output by counting them.</p>
<h3 id="expect"><a href="/transforms/expect">Expect</a></h3>
<p>The expectation feature (<code>expect</code>) computes expectation of a measure with respect to a given function. </p>
<h3 id="normalize"><a href="/transforms/normalize">Normalize</a></h3>
<p>The normalization transformation (<code>normalize</code>) reweights a program so that it represents a normal distribution.</p>
<h3 id="disintegrate"><a href="/transforms/disintegrate">Disintegrate</a></h3>
<p>The disintegration transformation (<code>disintegrate</code>) produces a program representing the conditional distribution based on a joint probability distribution. This command
is equivalent to model conditioning in probability theory. </p>
<h3 id="density"><a href="/transforms/density">Density</a></h3>
<p>The density transformation (<code>density</code>) is used to create a conditional distribution model that is used to estimate the density of the distribution at a particular point.</p>
<h3 id="hakaru-maple"><a href="/transforms/hk-maple">Hakaru-Maple</a></h3>
<p>The simplify transformation (<code>hk-maple -c Simplify</code>) is used to improve Hakaru programs by simplifying probabilistic models using computer algebra. This transformation requires the
use of Maple. Hakaru provides two other transformations also written in Maple.</p>
<h3 id="metropolis-hastings"><a href="/transforms/mh">Metropolis Hastings</a></h3>
<p>The Metropolis Hastings transform (<code>mh</code>) is used to convert a Hakaru program into a Metropolis Hastings transition kernel.</p>
<h2 id="internals">Internals</h2>
<p>The internals section of the manual provides some insight into how Hakaru is implemented and offers guidance into how the system can be extended.</p>
<ul>
<li><a href="/internals/ast">AST</a></li>
<li><a href="/internals/abt">ABT</a></li>
<li><a href="/internals/datums">Datums</a></li>
<li><a href="/internals/coercions">Coercions</a></li>
<li><a href="/internals/transforms">Transformations</a></li>
<li><a href="/internals/testing">Testing Hakaru modules</a></li>
<li><a href="/internals/newfeature">Adding a Language Feature</a></li>
</ul>
<h2 id="citing-us">Citing Us</h2>
<p>When referring to Hakaru, please cite the following <a href="http://homes.soic.indiana.edu/ccshan/rational/system.pdf">academic paper</a>:</p>
<p>P. Narayanan, J. Carette, W. Romano, C. Shan and R. Zinkov, “Probabilistic Inference by Program Transformation in Hakaru (System Description)”, Functional and Logic
Programming, pp. 62-79, 2016.</p>
<pre><code class="nohighlight">@inproceedings{narayanan2016probabilistic,
title = {Probabilistic inference by program transformation in Hakaru (system description)},
author = {Narayanan, Praveen and Carette, Jacques and Romano, Wren and Shan, Chung{-}chieh and Zinkov, Robert},
booktitle = {International Symposium on Functional and Logic Programming - 13th International Symposium, {FLOPS} 2016, Kochi, Japan, March 4-6, 2016, Proceedings},
pages = {62--79},
year = {2016},
organization = {Springer},
url = {http://dx.doi.org/10.1007/978-3-319-29604-3_5},
doi = {10.1007/978-3-319-29604-3_5},
}
</code></pre></div>
</div>
<footer class="col-md-12">
<hr>
<p>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</p>
</footer>
<script>
var base_url = ".",
shortcuts = {"help": 191, "next": 78, "previous": 80, "search": 83};
</script>
<script src="js/base.js" defer></script>
<script src="js/mathjaxhelper.js" defer></script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" defer></script>
<script src="search/main.js" defer></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
</div>
<div class="modal-body">
<p>
From here you can search these documents. Enter
your search terms below.
</p>
<form role="form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query" title="Type search term here">
</div>
</form>
<div id="mkdocs-search-results"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div><div class="modal" id="mkdocs_keyboard_modal" tabindex="-1" role="dialog" aria-labelledby="Keyboard Shortcuts Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Keyboard Shortcuts</h4>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th style="width: 20%;">Keys</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="help shortcut"><kbd>?</kbd></td>
<td>Open this help</td>
</tr>
<tr>
<td class="next shortcut"><kbd>n</kbd></td>
<td>Next page</td>
</tr>
<tr>
<td class="prev shortcut"><kbd>p</kbd></td>
<td>Previous page</td>
</tr>
<tr>
<td class="search shortcut"><kbd>s</kbd></td>
<td>Search</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>
<!--
MkDocs version : 1.0.4
Build Date UTC : 2020-07-17 16:46:05
-->