-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.html
572 lines (498 loc) · 34.4 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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>AdvancedMH.jl · AdvancedMH</title><meta name="title" content="AdvancedMH.jl · AdvancedMH"/><meta property="og:title" content="AdvancedMH.jl · AdvancedMH"/><meta property="twitter:title" content="AdvancedMH.jl · AdvancedMH"/><meta name="description" content="Documentation for AdvancedMH."/><meta property="og:description" content="Documentation for AdvancedMH."/><meta property="twitter:description" content="Documentation for AdvancedMH."/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body>
<!-- NAVBAR START -->
<style>
html {
scroll-padding-top: calc(55px + 1rem);
}
/* Documenter css tweaks */
.docs-sidebar {
margin-top: 3.75rem;
}
#documenter {
margin-top: 3.75rem;
}
.docs-version-selector {
margin-bottom: 60px !important;
}
@media screen and (max-width: 1056px) {
.docs-version-selector {
margin-bottom: 60px !important;
}
.docs-sidebar {
margin-top: 0 !important;
}
}
/* Documenter css tweaks ends here */
:root {
--heading-color: white;
--item-color: rgb(165, 165, 165);
--primary-bg: #073c44;
--hover-color: #8faad2;
}
.ext-navigation {
position: fixed;
height: 3.75rem;
top: 0;
width: 100%;
background-color: var(--primary-bg);
z-index: 1000;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
padding: 0 1.0625rem;
transition: transform 0.3s;
}
.ext-navbar-logo {
margin-left: 0.625rem;
}
.ext-nav-links {
display: flex;
align-items: center;
list-style-type: none;
margin: 0;
padding: 0;
flex-grow: 1;
}
.ext-nav-links li {
margin-left: 1rem !important;
}
.ext-nav-link {
color: white !important;
text-decoration: none;
font-size: 1.0625rem !important;
transition: color 0.2s ease;
cursor: pointer;
}
.ext-nav-link:hover,
.ext-navbar-item-single a:hover {
color: var(--hover-color) !important;
}
.ext-navbar-item-single a {
color: #fff !important;
}
.ext-menu-toggle {
display: none;
font-size: 1.5rem;
color: white;
cursor: pointer;
}
.ext-dropdown {
display: none;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: auto auto auto;
padding: 1.875rem;
position: absolute;
width: 100%;
left: 0;
background-color: #083c44;
line-height: 1.875rem;
opacity: 0;
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
transform: translateY(-0.625rem);
}
#library-handler::after {
content: "▼";
font-size: 0.6875rem;
margin-left: 0.3125rem;
transition: transform 0.3s ease-in-out;
}
#library-handler.open::after {
content: "▲";
}
.ext-dropdown.show {
display: grid;
opacity: 1;
transform: translateY(0);
}
.ext-dropdown ul {
height: auto;
width: 12.5rem;
margin-bottom: 1.25rem;
}
.ext-dropdown ul li {
text-align: left;
}
.navbar-sub-item {
list-style: none;
}
.ext-dropdown ul a li {
color: var(--item-color);
width: 15.625rem;
border-radius: 3px;
padding: 0.125rem 0.625rem;
transition: background-color 0.2s ease;
}
.ext-dropdown ul a li:hover {
background-color: rgba(107, 107, 107, 0.5);
}
.ext-dropdown-item-heading {
color: var(--heading-color);
text-align: center;
}
/* Responsive styling */
@media (max-width: 966px) {
.ext-dropdown {
grid-template-columns: 1fr 1fr 1fr;
}
}
@media (max-width: 768px) {
.ext-nav-links {
display: none;
flex-direction: column;
width: 100%;
background-color: var(--primary-bg);
position: absolute;
top: 3.75rem;
left: 0;
padding: 0.625rem 0;
height: auto;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: rgb(141, 141, 141) grey;
}
.ext-nav-links.show {
display: flex;
}
.ext-nav-links li {
margin: 0.625rem 0;
text-align: center;
}
.ext-menu-toggle {
display: block;
margin-left: auto;
}
.ext-navigation.hide {
transform: translateY(-3.75rem);
}
.ext-dropdown {
place-content: center;
text-align: center;
grid-template-columns: 1fr;
line-height: 1.25rem;
padding: 0.625rem;
}
.ext-dropdown ul {
width: 100%;
text-align: center;
margin-bottom: 0.3125rem;
}
.ext-dropdown ul li {
text-align: center;
}
.ext-dropdown ul a li {
width: 100%;
}
.ext-dropdown ul a li:hover {
background-color: var(--primary-bg);
color: #fff;
}
/* Modified scroll bar */
.ext-nav-links::-webkit-scrollbar {
width: 5px;
}
.ext-nav-links::-webkit-scrollbar-track {
box-shadow: inset 0 0 5px grey;
}
.ext-nav-links::-webkit-scrollbar-thumb {
background: rgb(141, 141, 141);
border-radius: 3px;
}
.ext-nav-links::-webkit-scrollbar-thumb:hover {
background: #9b9b9b;
}
}
</style>
<nav class="ext-navigation">
<a href="https://turinglang.org/">
<img src="https://turinglang.org/assets/images/turing-logo.svg" alt="Turing Logo" class="ext-navbar-logo" height="24px" width="40px">
</a>
<a style="color: white !important; font-size: 21.25px !important; margin-left: 10px;" href="https://turinglang.org/">Turing.jl</a>
<ul class="ext-nav-links">
<li>
<a class="ext-nav-link" href="https://turinglang.org/docs/tutorials/docs-00-getting-started/">Get Started</a>
</li>
<li>
<a class="ext-nav-link" href="https://turinglang.org/docs/tutorials/00-introduction/">Tutorials</a>
</li>
<li>
<p class="ext-nav-link" id="library-handler">Libraries</p>
<div class="ext-dropdown" id="ext-dropdown-items">
<ul>
<li class="ext-dropdown-item-heading">Modelling Languages</li>
<a href="https://turinglang.org/DynamicPPL.jl/">
<li>DynamicPPL</li>
</a>
<a href="https://turinglang.org/JuliaBUGS.jl/">
<li>JuliaBUGS</li>
</a>
<a href="https://turinglang.org/TuringGLM.jl/">
<li>TuringGLM</li>
</a>
</ul>
<ul>
<li class="ext-dropdown-item-heading">MCMC</li>
<a href="https://turinglang.org/AdvancedHMC.jl/">
<li>AdvancedHMC</li>
</a>
<a href="https://turinglang.org/AbstractMCMC.jl/">
<li>AbstractMCMC</li>
</a>
<a href="https://github.com/theogf/ThermodynamicIntegration.jl">
<li>ThermodynamicIntegration</li>
</a>
<a href="https://turinglang.org/AdvancedPS.jl/">
<li>AdvancedPS</li>
</a>
<a href="https://turinglang.org/SliceSampling.jl/">
<li>SliceSampling</li>
</a>
<a href="https://turinglang.org/EllipticalSliceSampling.jl/">
<li>EllipticalSliceSampling</li>
</a>
<a href="https://turinglang.org/NestedSamplers.jl/">
<li>NestedSamplers</li>
</a>
</ul>
<ul>
<li class="ext-dropdown-item-heading">Diagnostics</li>
<a href="https://turinglang.org/MCMCChains.jl/">
<li>MCMCChains</li>
</a>
<a href="https://turinglang.org/MCMCDiagnosticTools.jl/">
<li>MCMCDiagnosticTools</li>
</a>
<a href="https://turinglang.org/ParetoSmooth.jl/">
<li>ParetoSmooth</li>
</a>
</ul>
<ul>
<li class="ext-dropdown-item-heading">Gaussian Processes</li>
<a href="https://juliagaussianprocesses.github.io/AbstractGPs.jl/">
<li>AbstractGPs</li>
</a>
<a href="https://juliagaussianprocesses.github.io/KernelFunctions.jl/">
<li>KernelFunctions</li>
</a>
<a href="https://juliagaussianprocesses.github.io/ApproximateGPs.jl/">
<li>ApproximateGPs</li>
</a>
</ul>
<ul>
<li class="ext-dropdown-item-heading ext-navbar-item-single">
<a href="https://turinglang.org/Bijectors.jl/">Bijectors</a>
</li>
</ul>
<ul>
<li class="ext-dropdown-item-heading ext-navbar-item-single">
<a href="https://turinglang.org/TuringCallbacks.jl/">TuringCallbacks</a>
</li>
</ul>
<ul>
<li class="ext-dropdown-item-heading ext-navbar-item-single">
<a href="https://turinglang.org/TuringBenchmarking.jl/">TuringBenchmarking</a>
</li>
</ul>
</div>
</li>
<li>
<a class="ext-nav-link" href="https://turinglang.org/news/">News</a>
</li>
<li>
<a class="ext-nav-link" href="https://turinglang.org/team/">Team</a>
</li>
</ul>
<a href="https://x.com/TuringLang" style="margin-left: 15px; padding-top: 2px">
<svg fill="#ffffff" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32px" height="32px" viewBox="-209.92 -209.92 931.84 931.84" xml:space="preserve" stroke="#ffffff">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<g id="7935ec95c421cee6d86eb22ecd12f847">
<path style="display: inline"
d="M459.186,151.787c0.203,4.501,0.305,9.023,0.305,13.565 c0,138.542-105.461,298.285-298.274,298.285c-59.209,0-114.322-17.357-160.716-47.104c8.212,0.973,16.546,1.47,25.012,1.47 c49.121,0,94.318-16.759,130.209-44.884c-45.887-0.841-84.596-31.154-97.938-72.804c6.408,1.227,12.968,1.886,19.73,1.886 c9.55,0,18.816-1.287,27.617-3.68c-47.955-9.633-84.1-52.001-84.1-102.795c0-0.446,0-0.882,0.011-1.318 c14.133,7.847,30.294,12.562,47.488,13.109c-28.134-18.796-46.637-50.885-46.637-87.262c0-19.212,5.16-37.218,14.193-52.7 c51.707,63.426,128.941,105.156,216.072,109.536c-1.784-7.675-2.718-15.674-2.718-23.896c0-57.891,46.941-104.832,104.832-104.832 c30.173,0,57.404,12.734,76.525,33.102c23.887-4.694,46.313-13.423,66.569-25.438c-7.827,24.485-24.434,45.025-46.089,58.002 c21.209-2.535,41.426-8.171,60.222-16.505C497.448,118.542,479.666,137.004,459.186,151.787z">
</path>
</g>
</g>
</svg>
</a>
<a href="https://github.com/TuringLang/Turing.jl">
<svg width="32px" height="32px" viewBox="-8.2 -8.2 36.40 36.40" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#000000">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<title>github [#142]</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke-width="0.0002" fill="none" fill-rule="evenodd">
<g id="Dribbble-Light-Preview" transform="translate(-140.000000, -7559.000000)" fill="#ffffff">
<g id="icons" transform="translate(56.000000, 160.000000)">
<path
d="M94,7399 C99.523,7399 104,7403.59 104,7409.253 C104,7413.782 101.138,7417.624 97.167,7418.981 C96.66,7419.082 96.48,7418.762 96.48,7418.489 C96.48,7418.151 96.492,7417.047 96.492,7415.675 C96.492,7414.719 96.172,7414.095 95.813,7413.777 C98.04,7413.523 100.38,7412.656 100.38,7408.718 C100.38,7407.598 99.992,7406.684 99.35,7405.966 C99.454,7405.707 99.797,7404.664 99.252,7403.252 C99.252,7403.252 98.414,7402.977 96.505,7404.303 C95.706,7404.076 94.85,7403.962 94,7403.958 C93.15,7403.962 92.295,7404.076 91.497,7404.303 C89.586,7402.977 88.746,7403.252 88.746,7403.252 C88.203,7404.664 88.546,7405.707 88.649,7405.966 C88.01,7406.684 87.619,7407.598 87.619,7408.718 C87.619,7412.646 89.954,7413.526 92.175,7413.785 C91.889,7414.041 91.63,7414.493 91.54,7415.156 C90.97,7415.418 89.522,7415.871 88.63,7414.304 C88.63,7414.304 88.101,7413.319 87.097,7413.247 C87.097,7413.247 86.122,7413.234 87.029,7413.87 C87.029,7413.87 87.684,7414.185 88.139,7415.37 C88.139,7415.37 88.726,7417.2 91.508,7416.58 C91.513,7417.437 91.522,7418.245 91.522,7418.489 C91.522,7418.76 91.338,7419.077 90.839,7418.982 C86.865,7417.627 84,7413.783 84,7409.253 C84,7403.59 88.478,7399 94,7399"
id="github-[#142]">
</path>
</g>
</g>
</g>
</g>
</svg>
</a>
<span class="ext-menu-toggle">☰</span>
</nav>
<script>
document.addEventListener("DOMContentLoaded", function () {
const menuToggle = document.querySelector(".ext-menu-toggle");
const navLinks = document.querySelector(".ext-nav-links");
const nav = document.querySelector(".ext-navigation");
const navigationHandler = document.getElementById("library-handler");
const navigationItemsContainer =
document.getElementById("ext-dropdown-items");
let lastScrollY = window.scrollY;
function setAppropriateHeight() {
if (window.innerWidth <= 768) {
const viewportHeight = window.innerHeight;
const navHeight = nav.offsetHeight;
navLinks.style.maxHeight = `${viewportHeight - navHeight}px`;
navLinks.style.overflowY = "auto";
} else {
navLinks.style.maxHeight = "";
navLinks.style.overflowY = "";
}
}
// Toggle main menu for mobile
menuToggle.addEventListener("click", () => {
navLinks.classList.toggle("show");
if (navLinks.classList.contains("show")) {
setAppropriateHeight();
// Ensure the dropdown is hidden when menu is first opened
navigationItemsContainer.style.display = "none";
navigationItemsContainer.classList.remove("show");
}
});
// Close menus if clicked outside
document.addEventListener("click", (event) => {
if (
!navLinks.contains(event.target) &&
!menuToggle.contains(event.target)
) {
navLinks.classList.remove("show");
navigationItemsContainer.classList.remove("show");
navigationHandler.classList.remove("open");
}
});
// Hide navigation bar on scroll down in mobile view
window.addEventListener("scroll", () => {
if (window.innerWidth <= 768) {
nav.classList.toggle("hide", window.scrollY > lastScrollY);
lastScrollY = window.scrollY;
}
});
// Library API script
navigationHandler.addEventListener("click", (event) => {
event.preventDefault(); // Prevent default action of the link
if (navigationItemsContainer.classList.contains("show")) {
navigationItemsContainer.classList.remove("show");
navigationHandler.classList.remove("open");
setTimeout(() => {
navigationItemsContainer.style.display = "none";
}, 500); // Match the timeout to the CSS transition duration
} else {
navigationItemsContainer.style.display = "grid";
navigationHandler.classList.add("open");
setTimeout(() => {
navigationItemsContainer.classList.add("show");
}, 10); // Delay to ensure the display change takes effect before adding class
}
setAppropriateHeight(); // Recalculate height when dropdown changes
});
// Handle window resize
window.addEventListener("resize", setAppropriateHeight);
// Initial setup
setAppropriateHeight();
});
</script>
<!-- NAVBAR END -->
<div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>AdvancedMH</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>AdvancedMH.jl</a><ul class="internal"><li><a class="tocitem" href="#Usage"><span>Usage</span></a></li><li><a class="tocitem" href="#Proposals"><span>Proposals</span></a></li><li><a class="tocitem" href="#Static-vs.-Random-Walk"><span>Static vs. Random Walk</span></a></li><li><a class="tocitem" href="#Multiple-chains"><span>Multiple chains</span></a></li><li><a class="tocitem" href="#Metropolis-adjusted-Langevin-algorithm-(MALA)"><span>Metropolis-adjusted Langevin algorithm (MALA)</span></a></li></ul></li><li><a class="tocitem" href="api/">AdvancedMH.jl</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>AdvancedMH.jl</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>AdvancedMH.jl</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/TuringLang/AdvancedMH.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/TuringLang/AdvancedMH.jl/blob/master/README.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="AdvancedMH.jl"><a class="docs-heading-anchor" href="#AdvancedMH.jl">AdvancedMH.jl</a><a id="AdvancedMH.jl-1"></a><a class="docs-heading-anchor-permalink" href="#AdvancedMH.jl" title="Permalink"></a></h1><p><a href="https://turinglang.github.io/AdvancedMH.jl/stable"><img src="https://img.shields.io/badge/docs-stable-blue.svg" alt="Stable"/></a> <a href="https://turinglang.github.io/AdvancedMH.jl/dev"><img src="https://img.shields.io/badge/docs-dev-blue.svg" alt="Dev"/></a> <a href="https://github.com/TuringLang/AdvancedMH.jl/actions/workflows/main.yml?query=branch%3Amaster"><img src="https://github.com/TuringLang/AdvancedMH.jl/actions/workflows/main.yml/badge.svg?branch=master" alt="AdvancedMH-CI"/></a></p><p>AdvancedMH.jl currently provides a robust implementation of random walk Metropolis-Hastings samplers.</p><p>Further development aims to provide a suite of adaptive Metropolis-Hastings implementations.</p><p>AdvancedMH works by allowing users to define composable <code>Proposal</code> structs in different formats.</p><h2 id="Usage"><a class="docs-heading-anchor" href="#Usage">Usage</a><a id="Usage-1"></a><a class="docs-heading-anchor-permalink" href="#Usage" title="Permalink"></a></h2><p>First, construct a <code>DensityModel</code>, which is a wrapper around the log density function for your inference problem. The <code>DensityModel</code> is then used in a <code>sample</code> call.</p><pre><code class="language-julia hljs"># Import the package.
using AdvancedMH
using Distributions
using MCMCChains
using LinearAlgebra
# Generate a set of data from the posterior we want to estimate.
data = rand(Normal(0, 1), 30)
# Define the components of a basic model.
insupport(θ) = θ[2] >= 0
dist(θ) = Normal(θ[1], θ[2])
density(θ) = insupport(θ) ? sum(logpdf.(dist(θ), data)) : -Inf
# Construct a DensityModel.
model = DensityModel(density)
# Set up our sampler with a joint multivariate Normal proposal.
spl = RWMH(MvNormal(zeros(2), I))
# Sample from the posterior.
chain = sample(model, spl, 100000; param_names=["μ", "σ"], chain_type=Chains)</code></pre><p>Output:</p><pre><code class="language-julia hljs">Object of type Chains, with data of type 100000×3×1 Array{Float64,3}
Iterations = 1:100000
Thinning interval = 1
Chains = 1
Samples per chain = 100000
internals = lp
parameters = μ, σ
2-element Array{ChainDataFrame,1}
Summary Statistics
│ Row │ parameters │ mean │ std │ naive_se │ mcse │ ess │ r_hat │
│ │ Symbol │ Float64 │ Float64 │ Float64 │ Float64 │ Any │ Any │
├─────┼────────────┼──────────┼──────────┼─────────────┼────────────┼─────────┼─────────┤
│ 1 │ μ │ 0.156152 │ 0.19963 │ 0.000631285 │ 0.00323033 │ 3911.73 │ 1.00009 │
│ 2 │ σ │ 1.07493 │ 0.150111 │ 0.000474693 │ 0.00240317 │ 3707.73 │ 1.00027 │
Quantiles
│ Row │ parameters │ 2.5% │ 25.0% │ 50.0% │ 75.0% │ 97.5% │
│ │ Symbol │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │
├─────┼────────────┼──────────┼───────────┼──────────┼──────────┼──────────┤
│ 1 │ μ │ -0.23361 │ 0.0297006 │ 0.159139 │ 0.283493 │ 0.558694 │
│ 2 │ σ │ 0.828288 │ 0.972682 │ 1.05804 │ 1.16155 │ 1.41349 │
</code></pre><h3 id="Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)"><a class="docs-heading-anchor" href="#Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)">Usage with <a href="https://github.com/tpapp/LogDensityProblems.jl"><code>LogDensityProblems.jl</code></a></a><a id="Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)-1"></a><a class="docs-heading-anchor-permalink" href="#Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)" title="Permalink"></a></h3><p>Alternatively, you can define your model with the <a href="https://github.com/tpapp/LogDensityProblems.jl"><code>LogDensityProblems.jl</code></a> interface:</p><pre><code class="language-julia hljs">using LogDensityProblems
# Use a struct instead of `typeof(density)` for sake of readability.
struct LogTargetDensity end
LogDensityProblems.logdensity(p::LogTargetDensity, θ) = density(θ) # standard multivariate normal
LogDensityProblems.dimension(p::LogTargetDensity) = 2
LogDensityProblems.capabilities(::LogTargetDensity) = LogDensityProblems.LogDensityOrder{0}()
sample(LogTargetDensity(), spl, 100000; param_names=["μ", "σ"], chain_type=Chains)</code></pre><h2 id="Proposals"><a class="docs-heading-anchor" href="#Proposals">Proposals</a><a id="Proposals-1"></a><a class="docs-heading-anchor-permalink" href="#Proposals" title="Permalink"></a></h2><p>AdvancedMH offers various methods of defining your inference problem. Behind the scenes, a <code>MetropolisHastings</code> sampler simply holds some set of <code>Proposal</code> structs. AdvancedMH will return posterior samples in the "shape" of the proposal provided – currently supported methods are <code>Array{Proposal}</code>, <code>Proposal</code>, and <code>NamedTuple{Proposal}</code>. For example, proposals can be created as:</p><pre><code class="language-julia hljs"># Provide a univariate proposal.
m1 = DensityModel(x -> logpdf(Normal(x,1), 1.0))
p1 = StaticProposal(Normal(0,1))
c1 = sample(m1, MetropolisHastings(p1), 100; chain_type=Vector{NamedTuple})
# Draw from a vector of distributions.
m2 = DensityModel(x -> logpdf(Normal(x[1], x[2]), 1.0))
p2 = StaticProposal([Normal(0,1), InverseGamma(2,3)])
c2 = sample(m2, MetropolisHastings(p2), 100; chain_type=Vector{NamedTuple})
# Draw from a `NamedTuple` of distributions.
m3 = DensityModel(x -> logpdf(Normal(x.a, x.b), 1.0))
p3 = (a=StaticProposal(Normal(0,1)), b=StaticProposal(InverseGamma(2,3)))
c3 = sample(m3, MetropolisHastings(p3), 100; chain_type=Vector{NamedTuple})
# Draw from a functional proposal.
m4 = DensityModel(x -> logpdf(Normal(x,1), 1.0))
p4 = StaticProposal((x=1.0) -> Normal(x, 1))
c4 = sample(m4, MetropolisHastings(p4), 100; chain_type=Vector{NamedTuple})</code></pre><h2 id="Static-vs.-Random-Walk"><a class="docs-heading-anchor" href="#Static-vs.-Random-Walk">Static vs. Random Walk</a><a id="Static-vs.-Random-Walk-1"></a><a class="docs-heading-anchor-permalink" href="#Static-vs.-Random-Walk" title="Permalink"></a></h2><p>Currently there are only two methods of inference available. Static MH simply draws from the prior, with no conditioning on the previous sample. Random walk will add the proposal to the previously observed value. If you are constructing a <code>Proposal</code> by hand, you can determine whether the proposal is a <code>StaticProposal</code> or a <code>RandomWalkProposal</code> using</p><pre><code class="language-julia hljs">static_prop = StaticProposal(Normal(0,1))
rw_prop = RandomWalkProposal(Normal(0,1))</code></pre><p>Different methods are easily composeable. One parameter can be static and another can be a random walk, each of which may be drawn from separate distributions.</p><h2 id="Multiple-chains"><a class="docs-heading-anchor" href="#Multiple-chains">Multiple chains</a><a id="Multiple-chains-1"></a><a class="docs-heading-anchor-permalink" href="#Multiple-chains" title="Permalink"></a></h2><p>AdvancedMH.jl implements the interface of <a href="https://github.com/TuringLang/AbstractMCMC.jl/">AbstractMCMC</a> which means sampling of multiple chains is supported for free:</p><pre><code class="language-julia hljs"># Sample 4 chains from the posterior serially, without thread or process parallelism.
chain = sample(model, spl, MCMCSerial(), 100000, 4; param_names=["μ","σ"], chain_type=Chains)
# Sample 4 chains from the posterior using multiple threads.
chain = sample(model, spl, MCMCThreads(), 100000, 4; param_names=["μ","σ"], chain_type=Chains)
# Sample 4 chains from the posterior using multiple processes.
chain = sample(model, spl, MCMCDistributed(), 100000, 4; param_names=["μ","σ"], chain_type=Chains)</code></pre><h2 id="Metropolis-adjusted-Langevin-algorithm-(MALA)"><a class="docs-heading-anchor" href="#Metropolis-adjusted-Langevin-algorithm-(MALA)">Metropolis-adjusted Langevin algorithm (MALA)</a><a id="Metropolis-adjusted-Langevin-algorithm-(MALA)-1"></a><a class="docs-heading-anchor-permalink" href="#Metropolis-adjusted-Langevin-algorithm-(MALA)" title="Permalink"></a></h2><p>AdvancedMH.jl also offers an implementation of <a href="https://en.wikipedia.org/wiki/Metropolis-adjusted_Langevin_algorithm">MALA</a> if the <code>ForwardDiff</code> and <code>DiffResults</code> packages are available. </p><p>A <code>MALA</code> sampler can be constructed by <code>MALA(proposal)</code> where <code>proposal</code> is a function that takes the gradient computed at the current sample. It is required to specify an initial sample <code>initial_params</code> when calling <code>sample</code>.</p><pre><code class="language-julia hljs"># Import the package.
using AdvancedMH
using Distributions
using MCMCChains
using ForwardDiff
using StructArrays
using LinearAlgebra
# Generate a set of data from the posterior we want to estimate.
data = rand(Normal(0, 1), 30)
# Define the components of a basic model.
insupport(θ) = θ[2] >= 0
dist(θ) = Normal(θ[1], θ[2])
density(θ) = insupport(θ) ? sum(logpdf.(dist(θ), data)) : -Inf
# Construct a DensityModel.
model = DensityModel(density)
# Set up the sampler with a multivariate Gaussian proposal.
σ² = 0.01
spl = MALA(x -> MvNormal((σ² / 2) .* x, σ² * I))
# Sample from the posterior.
chain = sample(model, spl, 100000; initial_params=ones(2), chain_type=StructArray, param_names=["μ", "σ"])</code></pre><h3 id="Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)-2"><a class="docs-heading-anchor" href="#Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)-2">Usage with <a href="https://github.com/tpapp/LogDensityProblems.jl"><code>LogDensityProblems.jl</code></a></a><a class="docs-heading-anchor-permalink" href="#Usage-with-[LogDensityProblems.jl](https://github.com/tpapp/LogDensityProblems.jl)-2" title="Permalink"></a></h3><p>As above, we can define the model with the LogDensityProblems.jl interface. We can implement the gradient of the log density function manually, or use <a href="https://github.com/tpapp/LogDensityProblemsAD.jl"><code>LogDensityProblemsAD.jl</code></a> to provide us with the gradient computation used in MALA. Using our implementation of the <code>LogDensityProblems.jl</code> interface above:</p><pre><code class="language-julia hljs">using LogDensityProblemsAD
model_with_ad = LogDensityProblemsAD.ADgradient(Val(:ForwardDiff), LogTargetDensity())
sample(model_with_ad, spl, 100000; initial_params=ones(2), chain_type=StructArray, param_names=["μ", "σ"])</code></pre></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="api/">AdvancedMH.jl »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.7.0 on <span class="colophon-date" title="Thursday 31 October 2024 15:24">Thursday 31 October 2024</span>. Using Julia version 1.11.1.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>