PageSourceSearch

https://mc-stan.org/

html mc-stan.org collected 2026-09-24 08:43:23 UTC 32,300 bytes, 791 lines download raw bytes

1<!DOCTYPE html>
2<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
3
4<meta charset="utf-8">
5<meta name="generator" content="quarto-1.6.39">
6
7<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
8
9<meta name="description" content="Stan combines powerful statistical modeling capabilities with user-friendly interfaces, an active community, and a commitment to open-source development.">
10
11<title>Stan</title>
12<style>
13code{white-space: pre-wrap;}
14span.smallcaps{font-variant: small-caps;}
15div.columns{display: flex; gap: min(4vw, 1.5em);}
16div.column{flex: auto; overflow-x: auto;}
17div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
18ul.task-list{list-style: none;}
19ul.task-list li input[type="checkbox"] {
20  width: 0.8em;
21  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
22  vertical-align: middle;
23}
24/* CSS for syntax highlighting */
25pre > code.sourceCode { white-space: pre; position: relative; }
26pre > code.sourceCode > span { line-height: 1.25; }
27pre > code.sourceCode > span:empty { height: 1.2em; }
28.sourceCode { overflow: visible; }
29code.sourceCode > span { color: inherit; text-decoration: inherit; }
30div.sourceCode { margin: 1em 0; }
31pre.sourceCode { margin: 0; }
32@media screen {
33div.sourceCode { overflow: auto; }
34}
35@media print {
36pre > code.sourceCode { white-space: pre-wrap; }
37pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
38}
39pre.numberSource code
40  { counter-reset: source-line 0; }
41pre.numberSource code > span
42  { position: relative; left: -4em; counter-increment: source-line; }
43pre.numberSource code > span > a:first-child::before
44  { content: counter(source-line);
45    position: relative; left: -1em; text-align: right; vertical-align: baseline;
46    border: none; display: inline-block;
47    -webkit-touch-callout: none; -webkit-user-select: none;
48    -khtml-user-select: none; -moz-user-select: none;
49    -ms-user-select: none; user-select: none;
50    padding: 0 4px; width: 4em;
51  }
52pre.numberSource { margin-left: 3em;  padding-left: 4px; }
53div.sourceCode
54  {   }
55@media screen {
56pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
57}
58</style>
59
60
61<script src="site_libs/quarto-nav/quarto-nav.js"></script>
vendor: 1 bytes, line 61
61
62<script src="site_libs/quarto-nav/headroom.min.js"></script>
vendor: 1 bytes, line 62
62
63<script src="site_libs/clipboard/clipboard.min.js"></script>
vendor: 1 bytes, line 63
63
64<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
vendor: 1 bytes, line 64
64
65<script src="site_libs/quarto-search/fuse.min.js"></script>
vendor: 1 bytes, line 65
65
66<script src="site_libs/quarto-search/quarto-search.js"></script>
66
67<meta name="quarto:offset" content="./">
68<link href="./img/logo_tm.png" rel="icon" type="image/png">
69<script src="site_libs/quarto-html/quarto.js"></script>
vendor: 1 bytes, line 69
69
70<script src="site_libs/quarto-html/popper.min.js"></script>
vendor: 1 bytes, line 70
70
71<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
vendor: 1 bytes, line 71
71
72<script src="site_libs/quarto-html/anchor.min.js"></script>
72
73<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
74<link href="site_libs/quarto-html/quarto-syntax-highlighting-05fe91a66cf75bbbb8c9664867fe5124.css" rel="stylesheet" class="quarto-color-scheme" id="quarto-text-highlighting-styles">
75<link href="site_libs/quarto-html/quarto-syntax-highlighting-dark-59fdbf2653e1aaac23acf64cc15a0d7d.css" rel="prefetch" class="quarto-color-scheme quarto-color-alternate" id="quarto-text-highlighting-styles">
76<script src="site_libs/bootstrap/bootstrap.min.js"></script>
76
77<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
78<link href="site_libs/bootstrap/bootstrap-e6cc5b20f6c32f48f68f4ab3f41e030b.min.css" rel="stylesheet" append-hash="true" class="quarto-color-scheme" id="quarto-bootstrap" data-mode="light">
79<link href="site_libs/bootstrap/bootstrap-dark-07df3c4a644a0f799b61391ca465b194.min.css" rel="prefetch" append-hash="true" class="quarto-color-scheme quarto-color-alternate" id="quarto-bootstrap" data-mode="dark">
80<script id="quarto-search-options" type="application/json">{
81  "location": "navbar",
82  "copy-button": false,
83  "collapse-after": 3,
84  "panel-placement": "end",
85  "type": "overlay",
86  "limit": 50,
87  "keyboard-shortcut": [
88    "f",
89    "/",
90    "s"
91  ],
92  "show-item-context": false,
93  "language": {
94    "search-no-results-text": "No results",
95    "search-matching-documents-text": "matching documents",
96    "search-copy-link-title": "Copy link to search",
97    "search-hide-matches-text": "Hide additional matches",
98    "search-more-match-text": "more match in this document",
99    "search-more-matches-text": "more matches in this document",
100    "search-clear-button-title": "Clear",
101    "search-text-placeholder": "",
102    "search-detached-cancel-button-title": "Cancel",
103    "search-submit-button-title": "Submit",
104    "search-label": "Search"
105  }
106}</script>
106
107
108
109<link rel="stylesheet" href="quarto-config/quarto_styles.css">
110<link rel="stylesheet" href="index.css">
111<meta property="og:title" content="Stan">
112<meta property="og:description" content="Stan combines powerful statistical modeling capabilities with user-friendly interfaces, an active community, and a commitment to open-source development.">
113<meta property="og:image" content="img/logo_tm.png">
114<meta property="og:site_name" content="Stan">
115</head>
116
117<body class="nav-fixed fullcontent">
118
119<div id="quarto-search-results"></div>
120  <header id="quarto-header" class="headroom fixed-top">
121    <nav class="navbar navbar-expand-lg " data-bs-theme="dark">
122      <div class="navbar-container container-fluid">
123      <div class="navbar-brand-container mx-auto">
124    <a href="./index.html" class="navbar-brand navbar-brand-logo">
125    <img src="./img/logo_tm.png" alt="Stan logo" class="navbar-logo">
126    </a>
127  </div>
128            <div id="quarto-search" class="" title="Search"></div>
129          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" role="menu" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
130  <span class="navbar-toggler-icon"></span>
131</button>
132          <div class="collapse navbar-collapse" id="navbarCollapse">
133            <ul class="navbar-nav navbar-nav-scroll me-auto">
134  <li class="nav-item">
135    <a class="nav-link active" href="./index.html" aria-current="page"> 
136<span class="menu-text">Stan</span></a>
137  </li>  
138  <li class="nav-item">
139    <a class="nav-link" href="./install/index.html"> 
140<span class="menu-text">Getting Started</span></a>
141  </li>  
142  <li class="nav-item">
143    <a class="nav-link" href="https://mc-stan.org/docs"> 
144<span class="menu-text">Documentation</span></a>
145  </li>  
146  <li class="nav-item dropdown ">
147    <a class="nav-link dropdown-toggle" href="#" id="nav-menu-learning-resources" role="link" data-bs-toggle="dropdown" aria-expanded="false">
148 <span class="menu-text">Learning Resources</span>
149    </a>
150    <ul class="dropdown-menu" aria-labelledby="nav-menu-learning-resources">    
151        <li>
152    <a class="dropdown-item" href="./learn-stan/tutorials.html">
153 <span class="dropdown-text">Tutorials</span></a>
154  </li>  
155        <li>
156    <a class="dropdown-item" href="./learn-stan/case-studies.html">
157 <span class="dropdown-text">Case Studies</span></a>
158  </li>  
159        <li>
160    <a class="dropdown-item" href="./learn-stan/stancon-talks.html">
161 <span class="dropdown-text">StanCon Talks</span></a>
162  </li>  
163        <li>
164    <a class="dropdown-item" href="./learn-stan/field-guides.html">
165 <span class="dropdown-text">Domain-specific</span></a>
166  </li>  
167        <li>
168    <a class="dropdown-item" href="./learn-stan/publications.html">
169 <span class="dropdown-text">Publications</span></a>
170  </li>  
171        <li>
172    <a class="dropdown-item" href="./learn-stan/diagnostics-warnings.html">
173 <span class="dropdown-text">Diagnostics and Warnings</span></a>
174  </li>  
175    </ul>
176  </li>
177  <li class="nav-item">
178    <a class="nav-link" href="./tools/index.html"> 
179<span class="menu-text">Tools</span></a>
180  </li>  
181  <li class="nav-item">
182    <a class="nav-link" href="./about/index.html"> 
183<span class="menu-text">About</span></a>
184  </li>  
185</ul>
186          </div> <!-- /navcollapse -->
187            <div class="quarto-navbar-tools tools-wide">
188    <a href="https://github.com/stan-dev" title="" class="quarto-navigation-tool px-1" aria-label=""><i class="bi bi-github"></i></a>
189    <a href="https://discourse.mc-stan.org" title="" class="quarto-navigation-tool px-1" aria-label=""><i class="bi bi-chat-text-fill"></i></a>
190  <a href="" class="quarto-color-scheme-toggle quarto-navigation-tool  px-1" onclick="window.quartoToggleColorScheme(); return false;" title="Toggle dark mode"><i class="bi"></i></a>
191</div>
192      </div> <!-- /container-fluid -->
193    </nav>
194</header>
195<!-- content -->
196<div id="quarto-content" class="quarto-container page-layout-custom page-navbar">
197<!-- sidebar -->
198<!-- margin-sidebar -->
199<!-- main -->
200
201
202
203
204<div class="hero-banner">
205<section id="stan-software-for-bayesian-data-analysis" class="content-block">
206<h1>Stan: Software for Bayesian Data&nbsp;Analysis</h1>
207<div class="hero-text grid">
208<div class="g-col-12 g-col-md-8">
209<h3 id="bayesian-modeling">Bayesian Modeling</h3>
210<p>Stan enables sophisticated statistical modeling using Bayesian inference, allowing for more accurate and interpretable results in complex data scenarios.</p>
211<h3 id="flexible-and-scalable">Flexible and Scalable</h3>
212<p>Stan’s probabilistic programming language is suitable for a wide range of applications, from simple linear regression to multi-level models and time-series anal
212ysis.</p>
213<h3 id="multi-language-cross-platform-toolkit">Multi-Language, Cross-Platform Toolkit</h3>
214<p>Interfaces for Python, Julia, R, and the Unix shell make it easy to use Stan in any programming environment, on laptops, clusters, or in the cloud. A rich ecosystem of tools for validation and visualization support decision-making and communication.</p>
215</div>
216<div class="g-col-12 g-col-md-4 hero-code">
217<div class="code-with-filename">
218<div class="code-with-filename-file">
219<pre><strong>bernoulli.stan</strong></pre>
220</div>
221<div class="sourceCode" id="cb1" data-filename="bernoulli.stan"><pre class="sourceCode stan"><code class="sourceCode stan"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">data</span> {</span>
222<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>  <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>&gt; N;</span>
223<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>  <span class="dt">array</span>[N] <span class="dt">int</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; y;</span>
224<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>}</span>
225<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="kw">parameters</span> {</span>
226<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>  <span class="dt">real</span>&lt;<span class="kw">lower</span>=<span class="dv">0</span>, <span class="kw">upper</span>=<span class="dv">1</span>&gt; theta;</span>
227<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>}</span>
228<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="kw">model</span> {</span>
229<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>  <span class="co">// uniform prior on interval 0,1</span></span>
230<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>  theta ~ beta(<span class="dv">1</span>, <span class="dv">1</span>);</span>
231<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>  y ~ bernoulli(theta);</span>
232<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>}</span></code></pre></div>
233</div>
234</div>
235</div>
236<div class="hero-buttons" style="position: relative; display: flex; justify-content: center;">
237<p><a href="install/" class="btn-action-primary btn-action btn btn-success btn-lg" role="button">Get Started</a></p>
238</div>
239</section>
240</div>
241<div class="content-block">
242<h3 id="community-resources">Community Resources</h3>
243<ul>
244<li><p>The Stan <a href="https://discourse.mc-stan.org">forums</a> provide support for all user levels and topics, from installing software, to writing Stan programs, to advanced Bayesian modeling techniques and methodology.</p></li>
245<li><p>Stan’s <a href="https://mc-stan.org/docs">documentation</a>, <a href="./learn-stan/tutorials.html">tutorials</a>, and <a href="./learn-stan/case-studies.html">case studies</a> help users learn and use Stan effectively in their own projects. The <a href="https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations">Prior Choice Recommendations</a> wiki page provides guidance on appropriate priors for use with Stan.</p></li>
246</ul>
247<hr>
248<h3 id="developer-resources">Developer Resources</h3>
249<ul>
250<li><p>The <a href="https://github.com/stan-dev/stan/wiki">Stan Developer Wiki</a></p></li>
251<li><p>The <a href="https://discourse.mc-stan.org/c/stan-dev/10">Stan Forums Developers category</a></p></li>
252<li><p>The Stan slack channel <a href="https://join.slack.com/t/mc-stan/shared_invite/zt-1le4ebi4m-UMtiOkJb4gcS16qz2wIYCw">mc-stan.slack.com</a> is for informal developer discussions.</p></li>
253</ul>
254</div>
255
256
257
258
259<script id="quarto-html-after-body" type="application/javascript">
260window.document.addEventListener("DOMContentLoaded", function (event) {
261  const toggleBodyColorMode = (bsSheetEl) => {
262    const mode = bsSheetEl.getAttribute("data-mode");
263    const bodyEl = window.document.querySelector("body");
264    if (mode === "dark") {
265      bodyEl.classList.add("quarto-dark");
266      bodyEl.classList.remove("quarto-light");
267    } else {
268      bodyEl.classList.add("quarto-light");
269      bodyEl.classList.remove("quarto-dark");
270    }
271  }
272  const toggleBodyColorPrimary = () => {
273    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
274    if (bsSheetEl) {
275      toggleBodyColorMode(bsSheetEl);
276    }
277  }
278  toggleBodyColorPrimary();  
279  const disableStylesheet = (stylesheets) => {
280    for (let i=0; i < stylesheets.length; i++) {
281      const stylesheet = stylesheets[i];
282      stylesheet.rel = 'prefetch';
283    }
284  }
285  const enableStylesheet = (stylesheets) => {
286    for (let i=0; i < stylesheets.length; i++) {
287      const stylesheet = stylesheets[i];
288      stylesheet.rel = 'stylesheet';
289    }
290  }
291  const manageTransitions = (selector, allowTransitions) => {
292    const els = window.document.querySelectorAll(selector);
293    for (let i=0; i < els.length; i++) {
294      const el = els[i];
295      if (allowTransitions) {
296        el.classList.remove('notransition');
297      } else {
298        el.classList.add('notransition');
299      }
300    }
301  }
302  const toggleGiscusIfUsed = (isAlternate, darkModeDefault) => {
303    const baseTheme = document.querySelector('#giscus-base-theme')?.value ?? 'light';
304    const alternateTheme = document.querySelector('#giscus-alt-theme')?.value ?? 'dark';
305    let newTheme = '';
306    if(darkModeDefault) {
307      newTheme = isAlternate ? baseTheme : alternateTheme;
308    } else {
309      newTheme = isAlternate ? alternateTheme : baseTheme;
310    }
311    const changeGiscusTheme = () => {
312      // From: https://github.com/giscus/giscus/issues/336
313      const sendMessage = (message) => {
314        const iframe = document.querySelector('iframe.giscus-frame');
315        if (!iframe) return;
316        iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app');
317      }
318      sendMessage({
319        setConfig: {
320          theme: newTheme
321        }
322      });
323    }
324    const isGiscussLoaded = window.document.querySelector('iframe.giscus-frame') !== null;
325    if (isGiscussLoaded) {
326      changeGiscusTheme();
327    }
328  }
329  const toggleColorMode = (alternate) => {
330    // Switch the stylesheets
331    const alternateStylesheets = window.document.querySelectorAll('link.quarto-color-scheme.quarto-color-alternate');
332    manageTransitions('#quarto-margin-sidebar .nav-link', false);
333    if (alternate) {
334      enableStylesheet(alternateStylesheets);
335      for (const sheetNode of alternateStylesheets) {
336        if (sheetNode.id === "quarto-bootstrap") {
337          toggleBodyColorMode(sheetNode);
338        }
339      }
340    } else {
341      disableStylesheet(alternateStylesheets);
342      toggleBodyColorPrimary();
343    }
344    manageTransitions('#quarto-margin-sidebar .nav-link', true);
345    // Switch the toggles
346    const toggles = window.document.querySelectorAll('.quarto-color-scheme-toggle');
347    for (let i=0; i < toggles.length; i++) {
348      const toggle = toggles[i];
349      if (toggle) {
350        if (alternate) {
351          toggle.classList.add("alternate");     
352        } else {
353          toggle.classList.remove("alternate");
354        }
355      }
356    }
357    // Hack to workaround the fact that safari doesn't
358    // properly recolor the scrollbar when toggling (#1455)
359    if (navigator.userAgent.indexOf('Safari') > 0 && navigator.userAgent.indexOf('Chrome') == -1) {
360      manageTransitions("body", false);
361      window.scrollTo(0, 1);
362      setTimeout(() => {
363        window.scrollTo(0, 0);
364        manageTransitions("body", true);
365      }, 40);  
366    }
367  }
368  const isFileUrl = () => { 
369    return window.location.protocol === 'file:';
370  }
371  const hasAlternateSentinel = () => {  
372    let styleSentinel = getColorSchemeSentinel();
373    if (styleSentinel !== null) {
374      return styleSentinel === "alternate";
375    } else {
376      return false;
377    }
378  }
379  const setStyleSentinel = (alternate) => {
380    const value = alternate ? "alternate" : "default";
381    if (!isFileUrl()) {
382      window.localStorage.setItem("quarto-color-scheme", value);
383    } else {
384      localAlternateSentinel = value;
385    }
386  }
387  const getColorSchemeSentinel = () => {
388    if (!isFileUrl()) {
389      const storageValue = window.localStorage.getItem("quarto-color-scheme");
390      return storageValue != null ? storageValue : localAlternateSentinel;
391    } else {
392      return localAlternateSentinel;
393    }
394  }
395  const darkModeDefault = false;
396  let localAlternateSentinel = darkModeDefault ? 'alternate' : 'default';
397  // Dark / light mode switch
398  window.quartoToggleColorScheme = () => {
399    // Read the current dark / light value 
400    let toAlternate = !hasAlternateSentinel();
401    toggleColorMode(toAlternate);
402    setStyleSentinel(toAlternate);
403    toggleGiscusIfUsed(toAlternate, darkModeDefault);
404  };
405  // Ensure there is a toggle, if there isn't float one in the top right
406  if (window.document.querySelector('.quarto-color-scheme-toggle') === null) {
407    const a = window.document.createElement('a');
408    a.classList.add('top-right');
409    a.classList.add('quarto-color-scheme-toggle');
410    a.href = "";
411    a.onclick = function() { try { window.quartoToggleColorScheme(); } catch {} return false; };
412    const i = window.document.createElement("i");
413    i.classList.add('bi');
414    a.appendChild(i);
415    window.document.body.appendChild(a);
416  }
417  // Switch to dark mode if need be
418  if (hasAlternateSentinel()) {
419    toggleColorMode(true);
420  } else {
421    toggleColorMode(false);
422  }
423  const icon = "";
424  const anchorJS = new window.AnchorJS();
425  anchorJS.options = {
426    placement: 'right',
427    icon: icon
428  };
429  anchorJS.add('.anchored');
430    var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
431    var mailtoRegex = new RegExp(/^mailto:/);
432      var filterRegex = new RegExp('/' + window.location.host + '/');
433    var isInternal = (href) => {
434        return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
435    }
436    // Inspect non-navigation links and adorn them if external
437 	var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)');
438    for (var i=0; i<links.length; i++) {
439      const link = links[i];
440      if (!isInternal(link.href)) {
441        // undo the damage that might have been done by quarto-nav.js in the case of
442        // links that we want to consider external
443        if (link.dataset.originalHref !== undefined) {
444          link.href = link.dataset.originalHref;
445        }
446      }
447    }
448  function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
449    const config = {
450      allowHTML: true,
451      maxWidth: 500,
452      delay: 100,
453      arrow: false,
454      appendTo: function(el) {
455          return el.parentElement;
456      },
457      interactive: true,
458      interactiveBorder: 10,
459      theme: 'quarto',
460      placement: 'bottom-start',
461    };
462    if (contentFn) {
463      config.content = contentFn;
464    }
465    if (onTriggerFn) {
466      config.onTrigger = onTriggerFn;
467    }
468    if (onUntriggerFn) {
469      config.onUntrigger = onUntriggerFn;
470    }
471    window.tippy(el, config); 
472  }
473  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
474  for (var i=0; i<noterefs.length; i++) {
475    const ref = noterefs[i];
476    tippyHover(ref, function() {
477      // use id or data attribute instead here
478      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
479      try { href = new URL(href).hash; } catch {}
480      const id = href.replace(/^#\/?/, "");
481      const note = window.document.getElementById(id);
482      if (note) {
483        return note.innerHTML;
484      } else {
485        return "";
486      }
487    });
488  }
489  const xrefs = window.document.querySelectorAll('a.quarto-xref');
490  const processXRef = (id, note) => {
491    // Strip column container classes
492    const stripColumnClz = (el) => {
493      el.classList.remove("page-full", "page-columns");
494      if (el.children) {
495        for (const child of el.children) {
496          stripColumnClz(child);
497        }
498      }
499    }
500    stripColumnClz(note)
501    if (id === null || id.startsWith('sec-')) {
502      // Special case sections, only their first couple elements
503      const container = document.createElement("div");
504      if (note.children && note.children.length > 2) {
505        container.appendChild(note.children[0].cloneNode(true));
506        for (let i = 1; i < note.children.length; i++) {
507          const child = note.children[i];
508          if (child.tagName === "P" && child.innerText === "") {
509            continue;
510          } else {
511            container.appendChild(child.cloneNode(true));
512            break;
513          }
514        }
515        if (window.Quarto?.typesetMath) {
516          window.Quarto.typesetMath(container);
517        }
518        return container.innerHTML
519      } else {
520        if (window.Quarto?.typesetMath) {
521          window.Quarto.typesetMath(note);
522        }
523        return note.innerHTML;
524      }
525    } else {
526      // Remove any anchor links if they are present
527      const anchorLink = note.querySelector('a.anchorjs-link');
528      if (anchorLink) {
529        anchorLink.remove();
530      }
531      if (window.Quarto?.typesetMath) {
532        window.Quarto.typesetMath(note);
533      }
534      if (note.classList.contains("callout")) {
535        return note.outerHTML;
536      } else {
537        return note.innerHTML;
538      }
539    }
540  }
541  for (var i=0; i<xrefs.length; i++) {
542    const xref = xrefs[i];
543    tippyHover(xref, undefined, function(instance) {
544      instance.disable();
545      let url = xref.getAttribute('href');
546      let hash = undefined; 
547      if (url.startsWith('#')) {
548        hash = url;
549      } else {
550        try { hash = new URL(url).hash; } catch {}
551      }
552      if (hash) {
553        const id = hash.replace(/^#\/?/, "");
554        const note = window.document.getElementById(id);
555        if (note !== null) {
556          try {
557            const html = processXRef(id, note.cloneNode(true));
558            instance.setContent(html);
559          } finally {
560            instance.enable();
561            instance.show();
562          }
563        } else {
564          // See if we can fetch this
565          fetch(url.split('#')[0])
566          .then(res => res.text())
567          .then(html => {
568            const parser = new DOMParser();
569            const htmlDoc = parser.parseFromString(html, "text/html");
570            const note = htmlDoc.getElementById(id);
571            if (note !== null) {
572              const html = processXRef(id, note);
573              instance.setContent(html);
574            } 
575          }).finally(() => {
576            instance.enable();
577            instance.show();
578          });
579        }
580      } else {
581        // See if we can fetch a full url (with no hash to target)
582        // This is a special case and we should probably do some content thinning / targeting
583        fetch(url)
584        .then(res => res.text())
585        .then(html => {
586          const parser = new DOMParser();
587          const htmlDoc = parser.parseFromString(html, "text/html");
588          const note = htmlDoc.querySelector('main.content');
589          if (note !== null) {
590            // This should only happen for chapter cross references
591            // (since there is no id in the URL)
592            // remove the first header
593            if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
594              note.children[0].remove();
595            }
596            const html = processXRef(null, note);
597            instance.setContent(html);
598          } 
599        }).finally(() => {
600          instance.enable();
601          instance.show();
602        });
603      }
604    }, function(instance) {
605    });
606  }
607      let selectedAnnoteEl;
608      const selectorForAnnotation = ( cell, annotation) => {
609        let cellAttr = 'data-code-cell="' + cell + '"';
610        let lineAttr = 'data-code-annotation="' +  annotation + '"';
611        const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
612        return selector;
613      }
614      const selectCodeLines = (annoteEl) => {
615        const doc = window.document;
616        const targetCell = annoteEl.getAttribute("data-target-cell");
617        const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
618        const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
619        const lines = annoteSpan.getAttribute("data-code-lines").split(",");
620        const lineIds = lines.map((line) => {
621          return targetCell + "-" + line;
622        })
623        let top = null;
624        let height = null;
625        let parent = null;
626        if (lineIds.length > 0) {
627            //compute the position of the single el (top and bottom and make a div)
628            const el = window.document.getElementById(lineIds[0]);
629            top = el.offsetTop;
630            height = el.offsetHeight;
631            parent = el.parentElement.parentElement;
632          if (lineIds.length > 1) {
633            const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
634            const bottom = lastEl.offsetTop + lastEl.offsetHeight;
635            height = bottom - top;
636          }
637          if (top !== null && height !== null && parent !== null) {
638            // cook up a div (if necessary) and position it 
639            let div = window.document.getElementById("code-annotation-line-highlight");
640            if (div === null) {
641              div = window.document.createElement("div");
642              div.setAttribute("id", "code-annotation-line-highlight");
643              div.style.position = 'absolute';
644              parent.appendChild(div);
645            }
646            div.style.top = top - 2 + "px";
647            div.style.height = height + 4 + "px";
648            div.style.left = 0;
649            let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
650            if (gutterDiv === null) {
651              gutterDiv = window.document.createElement("div");
652              gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
653              gutterDiv.style.position = 'absolute';
654              const codeCell = window.document.getElementById(targetCell);
655              const gutter = codeCell.querySelector('.code-annotation-gutter');
656              gutter.appendChild(gutterDiv);
657            }
658            gutterDiv.style.top = top - 2 + "px";
659            gutterDiv.style.height = height + 4 + "px";
660          }
661          selectedAnnoteEl = annoteEl;
662        }
663      };
664      const unselectCodeLines = () => {
665        const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
666        elementsIds.forEach((elId) => {
667          const div = window.document.getElementById(elId);
668          if (div) {
669            div.remove();
670          }
671        });
672        selectedAnnoteEl = undefined;
673      };
674        // Handle positioning of the toggle
675    window.addEventListener(
676      "resize",
677      throttle(() => {
678        elRect = undefined;
679        if (selectedAnnoteEl) {
680          selectCodeLines(selectedAnnoteEl);
681        }
682      }, 10)
683    );
684    function throttle(fn, ms) {
685    let throttle = false;
686    let timer;
687      return (...args) => {
688        if(!throttle) { // first call gets through
689            fn.apply(this, args);
690            throttle = true;
691        } else { // all the others get throttled
692            if(timer) clearTimeout(timer); // cancel #2
693            timer = setTimeout(() => {
694              fn.apply(this, args);
695              timer = throttle = false;
696            }, ms);
697        }
698      };
699    }
700      // Attach click handler to the DT
701      const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
702      for (const annoteDlNode of annoteDls) {
703        annoteDlNode.addEventListener('click', (event) => {
704          const clickedEl = event.target;
705          if (clickedEl !== selectedAnnoteEl) {
706            unselectCodeLines();
707            const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
708            if (activeEl) {
709              activeEl.classList.remove('code-annotation-active');
710            }
711            selectCodeLines(clickedEl);
712            clickedEl.classList.add('code-annotation-active');
713          } else {
714            // Unselect the line
715            unselectCodeLines();
716            clickedEl.classList.remove('code-annotation-active');
717          }
718        });
719      }
720  const findCites = (el) => {
721    const parentEl = el.parentElement;
722    if (parentEl) {
723      const cites = parentEl.dataset.cites;
724      if (cites) {
725        return {
726          el,
727          cites: cites.split(' ')
728        };
729      } else {
730        return findCites(el.parentElement)
731      }
732    } else {
733      return undefined;
734    }
735  };
736  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
737  for (var i=0; i<bibliorefs.length; i++) {
738    const ref = bibliorefs[i];
739    const citeInfo = findCites(ref);
740    if (citeInfo) {
741      tippyHover(citeInfo.el, function() {
742        var popup = window.document.createElement('div');
743        citeInfo.cites.forEach(function(cite) {
744          var citeDiv = window.document.createElement('div');
745          citeDiv.classList.add('hanging-indent');
746          citeDiv.classList.add('csl-entry');
747          var biblioDiv = window.document.getElementById('ref-' + cite);
748          if (biblioDiv) {
749            citeDiv.innerHTML = biblioDiv.innerHTML;
750          }
751          popup.appendChild(citeDiv);
752        });
753        return popup.innerHTML;
754      });
755    }
756  }
757});
758</script>
758
759</div> <!-- /content -->
760<script>
761// Workaround for Safari not scrolling to URL fragment identifiers
762// on fresh page loads. Uses MutationObserver to wait for Quarto's
763// post-load DOM rendering (sidebar, TOC, MathJax) to settle before
764// scrolling. Scrolls as soon as DOM changes stop for 80ms.
765window.addEventListener('load', function () {
766  if (!window.location.hash) return;
767  var el = document.querySelector(window.location.hash);
768  if (!el) return;
769
770  var timer;
771  var observer = new MutationObserver(function () {
772    clearTimeout(timer);
773    timer = setTimeout(function () {
774      observer.disconnect();
775      el.scrollIntoView();
776    }, 80);
777  });
778
779  observer.observe(document.body, { childList: true, subtree: true });
780
781  timer = setTimeout(function () {
782    observer.disconnect();
783    el.scrollIntoView();
784  }, 80);
785});
786</script>
786
787
788
789
790
791</body></html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.