Skip to content

Commit

Permalink
build based on 25c9d18
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Aug 12, 2024
1 parent 85b68e8 commit 3f70ed1
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 110 deletions.
2 changes: 1 addition & 1 deletion dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-12T02:29:09","documenter_version":"1.5.0"}}
{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-12T20:54:51","documenter_version":"1.5.0"}}
66 changes: 32 additions & 34 deletions dev/abstractmcmc_demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 56 additions & 7 deletions dev/general/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,72 @@
Iterations = 1:1:10000
Number of chains = 1
Samples per chain = 10000
Wall duration = 4.19 seconds
Compute duration = 4.19 seconds
Wall duration = 4.34 seconds
Compute duration = 4.34 seconds
parameters = s, m
internals = lp

Summary Statistics
<span class="sgr1"> parameters </span> <span class="sgr1"> mean </span> <span class="sgr1"> std </span> <span class="sgr1"> mcse </span> <span class="sgr1"> ess_bulk </span> <span class="sgr1"> ess_tail </span> <span class="sgr1"> rhat </span>
<span class="sgr90"> Symbol </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span>

s 1.5240 3.5438 0.0400 5837.6548 4743.5614 1.0002
m -0.0051 1.2245 0.0129 8940.8834 5833.9653 0.9999
s 1.5399 1.4716 0.0245 5546.7713 4499.4552 1.0001
m -0.0006 1.2366 0.0135 8507.9126 5682.3507 1.0006
<span class="sgr36"> 1 column omitted</span>

Quantiles
<span class="sgr1"> parameters </span> <span class="sgr1"> 2.5% </span> <span class="sgr1"> 25.0% </span> <span class="sgr1"> 50.0% </span> <span class="sgr1"> 75.0% </span> <span class="sgr1"> 97.5% </span>
<span class="sgr90"> Symbol </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span>

s 0.4194 0.7580 1.1085 1.7324 4.8389
m -2.5320 -0.7309 -0.0006 0.7249 2.4190
</code></pre><h2 id="Drawing-Samples"><a class="docs-heading-anchor" href="#Drawing-Samples">Drawing Samples</a><a id="Drawing-Samples-1"></a><a class="docs-heading-anchor-permalink" href="#Drawing-Samples" title="Permalink"></a></h2><p>For drawing samples using the algorithms provided by <code>SliceSampling</code>, the user only needs to call:</p><pre><code class="language-julia hljs">sample([rng,] model, slice, N; initial_params)</code></pre><ul><li><code>slice::AbstractSliceSampling</code>: Any slice sampling algorithm provided by <code>SliceSampling</code>.</li><li><code>model</code>: A model implementing the <code>LogDensityProblems</code> interface.</li><li><code>N</code>: The number of samples</li></ul><p>The output is a <code>SliceSampling.Transition</code> object, which contains the following:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="SliceSampling.Transition" href="#SliceSampling.Transition"><code>SliceSampling.Transition</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">struct Transition</code></pre><p>Struct containing the results of the transition.</p><p><strong>Fields</strong></p><ul><li><code>params</code>: Samples generated by the transition.</li><li><code>lp::Real</code>: Log-target density of the samples.</li><li><code>info::NamedTuple</code>: Named tuple containing information about the transition. </li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SliceSampling.jl/blob/2e2efed4f389246cda9536955760029486327793/src/SliceSampling.jl#L24-L33">source</a></section></article><p>For the keyword arguments, <code>SliceSampling</code> allows:</p><ul><li><code>initial_params</code>: The intial state of the Markov chain (default: <code>nothing</code>).</li></ul><p>If <code>initial_params</code> is <code>nothing</code>, the following function can be implemented to provide an initialization:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="SliceSampling.initial_sample" href="#SliceSampling.initial_sample"><code>SliceSampling.initial_sample</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">initial_sample(rng, model)</code></pre><p>Return the initial sample for the <code>model</code> using the random number generator <code>rng</code>.</p><p><strong>Arguments</strong></p><ul><li><code>rng::Random.AbstractRNG</code>: Random number generator.</li><li><code>model</code>: The target <code>LogDensityProblem</code>.</li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SliceSampling.jl/blob/2e2efed4f389246cda9536955760029486327793/src/SliceSampling.jl#L45-L53">source</a></section></article><h2 id="Performing-a-Single-Transition"><a class="docs-heading-anchor" href="#Performing-a-Single-Transition">Performing a Single Transition</a><a id="Performing-a-Single-Transition-1"></a><a class="docs-heading-anchor-permalink" href="#Performing-a-Single-Transition" title="Permalink"></a></h2><p>For more fined-grained control, the user can call <code>AbstractMCMC.step</code>. That is, the chain can be initialized by calling:</p><pre><code class="language-julia hljs">transition, state = AbstractMCMC.steps([rng,] model, slice; initial_params)</code></pre><p>and then each MCMC transition on <code>state</code> can be performed by calling:</p><pre><code class="language-julia hljs">transition, state = AbstractMCMC.steps([rng,] model, slice, state)</code></pre><p>For more details, refer to the documentation of <code>AbstractMCMC</code>.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../univariate_slice/">Univariate Slice Sampling »</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.5.0 on <span class="colophon-date" title="Monday 12 August 2024 02:29">Monday 12 August 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
s 0.4144 0.7681 1.1400 1.7783 5.0932
m -2.4238 -0.7387 -0.0069 0.7363 2.4593
</code></pre><h3 id="Conditional-sampling-in-a-Turing.Experimental.Gibbs-sampler"><a class="docs-heading-anchor" href="#Conditional-sampling-in-a-Turing.Experimental.Gibbs-sampler">Conditional sampling in a <code>Turing.Experimental.Gibbs</code> sampler</a><a id="Conditional-sampling-in-a-Turing.Experimental.Gibbs-sampler-1"></a><a class="docs-heading-anchor-permalink" href="#Conditional-sampling-in-a-Turing.Experimental.Gibbs-sampler" title="Permalink"></a></h3><p><code>SliceSampling.jl</code> be used as a conditional sampler in <code>Turing.Experimental.Gibbs</code>.</p><pre><code class="language-julia hljs">using Distributions
using Turing
using SliceSampling

@model function simple_choice(xs)
p ~ Beta(2, 2)
z ~ Bernoulli(p)
for i in 1:length(xs)
if z == 1
xs[i] ~ Normal(0, 1)
else
xs[i] ~ Normal(2, 1)
end
end
end

sampler = Turing.Experimental.Gibbs(
(
p = externalsampler(SliceSteppingOut(2.0)),
z = PG(20, :z)
)
)

n_samples = 1000
model = simple_choice([1.5, 2.0, 0.3])
sample(model, sampler, n_samples)</code></pre><pre class="documenter-example-output"><code class="nohighlight hljs ansi">Chains MCMC chain (1000×3×1 Array{Float64, 3}):

Iterations = 1:1:1000
Number of chains = 1
Samples per chain = 1000
Wall duration = 20.19 seconds
Compute duration = 20.19 seconds
parameters = p, z
internals = lp

Summary Statistics
<span class="sgr1"> parameters </span> <span class="sgr1"> mean </span> <span class="sgr1"> std </span> <span class="sgr1"> mcse </span> <span class="sgr1"> ess_bulk </span> <span class="sgr1"> ess_tail </span> <span class="sgr1"> rhat </span> <span class="sgr1"> e</span>
<span class="sgr90"> Symbol </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> </span>

p 0.6038 0.1975 0.0063 964.8447 619.8975 1.0005 ⋯
z 0.3010 0.4589 0.0166 767.5188 NaN 0.9994 ⋯
<span class="sgr36"> 1 column omitted</span>

Quantiles
<span class="sgr1"> parameters </span> <span class="sgr1"> 2.5% </span> <span class="sgr1"> 25.0% </span> <span class="sgr1"> 50.0% </span> <span class="sgr1"> 75.0% </span> <span class="sgr1"> 97.5% </span>
<span class="sgr90"> Symbol </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span> <span class="sgr90"> Float64 </span>

p 0.2117 0.4566 0.6201 0.7511 0.9319
z 0.0000 0.0000 0.0000 1.0000 1.0000
</code></pre><h2 id="Drawing-Samples"><a class="docs-heading-anchor" href="#Drawing-Samples">Drawing Samples</a><a id="Drawing-Samples-1"></a><a class="docs-heading-anchor-permalink" href="#Drawing-Samples" title="Permalink"></a></h2><p>For drawing samples using the algorithms provided by <code>SliceSampling</code>, the user only needs to call:</p><pre><code class="language-julia hljs">sample([rng,] model, slice, N; initial_params)</code></pre><ul><li><code>slice::AbstractSliceSampling</code>: Any slice sampling algorithm provided by <code>SliceSampling</code>.</li><li><code>model</code>: A model implementing the <code>LogDensityProblems</code> interface.</li><li><code>N</code>: The number of samples</li></ul><p>The output is a <code>SliceSampling.Transition</code> object, which contains the following:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="SliceSampling.Transition" href="#SliceSampling.Transition"><code>SliceSampling.Transition</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">struct Transition</code></pre><p>Struct containing the results of the transition.</p><p><strong>Fields</strong></p><ul><li><code>params</code>: Samples generated by the transition.</li><li><code>lp::Real</code>: Log-target density of the samples.</li><li><code>info::NamedTuple</code>: Named tuple containing information about the transition. </li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SliceSampling.jl/blob/25c9d1845f8125a2660fd52b76f1f660426817b6/src/SliceSampling.jl#L24-L33">source</a></section></article><p>For the keyword arguments, <code>SliceSampling</code> allows:</p><ul><li><code>initial_params</code>: The intial state of the Markov chain (default: <code>nothing</code>).</li></ul><p>If <code>initial_params</code> is <code>nothing</code>, the following function can be implemented to provide an initialization:</p><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="SliceSampling.initial_sample" href="#SliceSampling.initial_sample"><code>SliceSampling.initial_sample</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">initial_sample(rng, model)</code></pre><p>Return the initial sample for the <code>model</code> using the random number generator <code>rng</code>.</p><p><strong>Arguments</strong></p><ul><li><code>rng::Random.AbstractRNG</code>: Random number generator.</li><li><code>model</code>: The target <code>LogDensityProblem</code>.</li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SliceSampling.jl/blob/25c9d1845f8125a2660fd52b76f1f660426817b6/src/SliceSampling.jl#L45-L53">source</a></section></article><h2 id="Performing-a-Single-Transition"><a class="docs-heading-anchor" href="#Performing-a-Single-Transition">Performing a Single Transition</a><a id="Performing-a-Single-Transition-1"></a><a class="docs-heading-anchor-permalink" href="#Performing-a-Single-Transition" title="Permalink"></a></h2><p>For more fined-grained control, the user can call <code>AbstractMCMC.step</code>. That is, the chain can be initialized by calling:</p><pre><code class="language-julia hljs">transition, state = AbstractMCMC.steps([rng,] model, slice; initial_params)</code></pre><p>and then each MCMC transition on <code>state</code> can be performed by calling:</p><pre><code class="language-julia hljs">transition, state = AbstractMCMC.steps([rng,] model, slice, state)</code></pre><p>For more details, refer to the documentation of <code>AbstractMCMC</code>.</p></article><nav class="docs-footer"><a class="docs-footer-prevpage" href="../">« Home</a><a class="docs-footer-nextpage" href="../univariate_slice/">Univariate Slice Sampling »</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.5.0 on <span class="colophon-date" title="Monday 12 August 2024 20:54">Monday 12 August 2024</span>. Using Julia version 1.10.4.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 3f70ed1

Please sign in to comment.