Skip to content

Commit

Permalink
build based on 4153da3
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed Sep 13, 2023
1 parent 5951093 commit 7af72e3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Binary file added dev/images/state_space_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 40 additions & 1 deletion dev/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Home · SSMProblems</title><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.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/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="siteinfo.js"></script><script src="../versions.js"></script><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><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>SSMProblems</a></span></div><form class="docs-search" action="search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>Home</a></li><li><span class="tocitem">Examples</span></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"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Home</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Home</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/TuringLang/SSMProblems.jl/blob/main/docs/src/index.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="SSMProblems"><a class="docs-heading-anchor" href="#SSMProblems">SSMProblems</a><a id="SSMProblems-1"></a><a class="docs-heading-anchor-permalink" href="#SSMProblems" title="Permalink"></a></h1><h3 id="API"><a class="docs-heading-anchor" href="#API">API</a><a id="API-1"></a><a class="docs-heading-anchor-permalink" href="#API" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.AbstractParticle" href="#SSMProblems.AbstractParticle"><code>SSMProblems.AbstractParticle</code></a><span class="docstring-category">Type</span></header><section><div></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/bfcf29c89a5ae3b23d9e24b1339e2473eed59679/src/SSMProblems.jl#L6">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.emission_logdensity" href="#SSMProblems.emission_logdensity"><code>SSMProblems.emission_logdensity</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">emission_logdensity(step, particle[, cache])</code></pre><p>Compute the log potential of current particle. This effectively &quot;reweight&quot; each particle.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/bfcf29c89a5ae3b23d9e24b1339e2473eed59679/src/SSMProblems.jl#L25-L29">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.isdone" href="#SSMProblems.isdone"><code>SSMProblems.isdone</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">isdone(step, particle[, cache])</code></pre><p>Determine whether we have reached the last time step of the Markov process. Return <code>true</code> if yes, otherwise return <code>false</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/bfcf29c89a5ae3b23d9e24b1339e2473eed59679/src/SSMProblems.jl#L32-L36">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.transition!!" href="#SSMProblems.transition!!"><code>SSMProblems.transition!!</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">transition!!(rng, step, particle[, cache])</code></pre><p>Simulate the particle for the next time step from the forward dynamics.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/bfcf29c89a5ae3b23d9e24b1339e2473eed59679/src/SSMProblems.jl#L11-L15">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.transition_logdensity" href="#SSMProblems.transition_logdensity"><code>SSMProblems.transition_logdensity</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">transition_logdensity(step, particle, x[, cache])</code></pre><p>(Optional) Computes the log-density of the forward transition if the density is available.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/bfcf29c89a5ae3b23d9e24b1339e2473eed59679/src/SSMProblems.jl#L18-L22">source</a></section></article></article><nav class="docs-footer"><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="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Friday 28 July 2023 15:42">Friday 28 July 2023</span>. Using Julia version 1.9.2.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Home · SSMProblems</title><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.045/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.24/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="siteinfo.js"></script><script src="../versions.js"></script><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><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>SSMProblems</a></span></div><form class="docs-search" action="search/"><input class="docs-search-query" id="documenter-search-query" name="q" type="text" placeholder="Search docs"/></form><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>Home</a></li><li><span class="tocitem">Examples</span></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"><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Home</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Home</a></li></ul></nav><div class="docs-right"><a class="docs-edit-link" href="https://github.com/TuringLang/SSMProblems.jl/blob/main/docs/src/index.md" title="Edit on GitHub"><span class="docs-icon fab"></span><span class="docs-label is-hidden-touch">Edit on GitHub</span></a><a class="docs-settings-button fas fa-cog" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-sidebar-button fa fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a></div></header><article class="content" id="documenter-page"><h1 id="SSMProblems"><a class="docs-heading-anchor" href="#SSMProblems">SSMProblems</a><a id="SSMProblems-1"></a><a class="docs-heading-anchor-permalink" href="#SSMProblems" title="Permalink"></a></h1><h3 id="Installation"><a class="docs-heading-anchor" href="#Installation">Installation</a><a id="Installation-1"></a><a class="docs-heading-anchor-permalink" href="#Installation" title="Permalink"></a></h3><p>In the <code>julia</code> REPL:</p><pre><code class="language-julia hljs">]add SSMProblems</code></pre><h3 id="Documentation"><a class="docs-heading-anchor" href="#Documentation">Documentation</a><a id="Documentation-1"></a><a class="docs-heading-anchor-permalink" href="#Documentation" title="Permalink"></a></h3><p><code>SSMProblems</code> defines a generic interface for State Space Problems (SSM). The main objective is to provide a consistent interface to work with SSMs and their logdensities.</p><p>Consider a markovian model from<sup class="footnote-reference"><a id="citeref-Murray" href="#footnote-Murray">[Murray]</a></sup>: <img src="./docs/images/state_space_model.png" alt="state space model"/></p><p>The model is fully specified by the following densities:</p><ul><li><strong>Initialisation</strong>: <span>$f_0(x)$</span></li><li><strong>Transition</strong>: <span>$f(x)$</span></li><li><strong>Emission</strong>: <span>$g(x)$</span></li></ul><p>And the dynamics of the model reduces to:</p><p class="math-container">\[\begin{aligned}
x_t | x_{t-1} &amp;\sim f(x_t | x_{t-1}) \\
y_t | x_t &amp;\sim g(y_t | x_{t})
\end{aligned}\]</p><p>assuming <span>$x_0 \sim f_0(x)$</span>. </p><p>The joint law follows:</p><p class="math-container">\[p(x_{0:T}, y_{0:T}) = f_0(x_0) \prod_t g(y_t | x_t) f(x_t | x_{t-1})\]</p><p>Users can define their SSM with <code>SSMProblems</code> in the following way:</p><pre><code class="language-julia hljs">struct Model &lt;: AbstractStateSpaceModel end

# Define the structure of the latent space
particleof(::Model) = Float64
dimension(::Model) = 2

function transition!!(
rng::Random.AbstractRNG,
step,
model::Model,
particle::AbstractParticl{&lt;:AbstractStateSpaceModel}
)
if step == 1
... # Sample from the initial density
end
... # Sample from the transition density
end

function emission_logdensity(step, model::Model, particle::AbstractParticle)
... # Return log density of the model at *time* `step`
end

isdone(step, model::Model, particle::AbstractParticle) = ... # Stops the state machine

# Optionally, if the transition density is known, the model can also specify it
function transition_logdensity(step, prev_particle::AbstractParticle, next_particle::AbstractParticle)
... # Scores the forward transition at `x`
end</code></pre><p>Package users can then consume the model <code>logdensity</code> through calls to <code>emission_logdensity</code>. </p><p>For example, a bootstrap filter targeting the filtering distribution <span>$p(x_t | y_{0:t})$</span> using <code>N</code> particles would roughly follow:</p><pre><code class="language-julia hljs">struct Particle{T&lt;:AbstractStateSpaceModel} &lt;: AbstractParticle{T} end

while !all(map(particle -&gt; isdone(t, model, particles), particles)):
ancestors = resample(rng, logweigths)
particles = particles[ancestors]
for i in 1:N
particles[i] = transition!!(rng, t, model, particles[i])
logweights[i] += emission_logdensity(t, model, particles[i])
end
end</code></pre><h3 id="Interface"><a class="docs-heading-anchor" href="#Interface">Interface</a><a id="Interface-1"></a><a class="docs-heading-anchor-permalink" href="#Interface" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.AbstractStateSpaceModel" href="#SSMProblems.AbstractStateSpaceModel"><code>SSMProblems.AbstractStateSpaceModel</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">AbstractStateSpaceModel</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/4153da33abb1db7c9ccf505d35cce5f9c0e52e3c/src/SSMProblems.jl#L6-L8">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.emission_logdensity" href="#SSMProblems.emission_logdensity"><code>SSMProblems.emission_logdensity</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">emission_logdensity(model, state, observation[, timestep, cache])</code></pre><p>Compute the log potential of the current particle. This effectively &quot;reweight&quot; each particle.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/4153da33abb1db7c9ccf505d35cce5f9c0e52e3c/src/SSMProblems.jl#L26-L30">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.transition!!" href="#SSMProblems.transition!!"><code>SSMProblems.transition!!</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">transition!!(rng, model[, state, timestep, cache])</code></pre><p>Simulate the particle for the next time step from the forward dynamics.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/4153da33abb1db7c9ccf505d35cce5f9c0e52e3c/src/SSMProblems.jl#L12-L16">source</a></section></article><article class="docstring"><header><a class="docstring-binding" id="SSMProblems.transition_logdensity" href="#SSMProblems.transition_logdensity"><code>SSMProblems.transition_logdensity</code></a><span class="docstring-category">Function</span></header><section><div><pre><code class="language-julia hljs">transition_logdensity(model, prev_state, current_state[, timestep, cache])</code></pre><p>(Optional) Computes the log-density of the forward transition if the density is available.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/TuringLang/SSMProblems.jl/blob/4153da33abb1db7c9ccf505d35cce5f9c0e52e3c/src/SSMProblems.jl#L19-L23">source</a></section></article><section class="footnotes is-size-7"><ul><li class="footnote" id="footnote-Murray"><a class="tag is-link" href="#citeref-Murray">Murray</a><blockquote><p>Murray, Lawrence &amp; Lee, Anthony &amp; Jacob, Pierre. (2013). Rethinking resampling in the particle filter on graphics processing units. </p></blockquote></li></ul></section></article><nav class="docs-footer"><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="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 0.27.25 on <span class="colophon-date" title="Wednesday 13 September 2023 22:32">Wednesday 13 September 2023</span>. Using Julia version 1.9.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>
Loading

0 comments on commit 7af72e3

Please sign in to comment.