diff --git a/previews/PR16/index.html b/previews/PR16/index.html index 720ba27..c717439 100644 --- a/previews/PR16/index.html +++ b/previews/PR16/index.html @@ -1,6 +1,8 @@ -Home · SSMProblems

SSMProblems

Installation

In the julia REPL:

]add SSMProblems

Documentation

SSMProblems 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.

Consider a markovian model from[Murray]: state space model

The model is fully specified by the following densities:

  • Initialisation: $f_0(x)$
  • Transition: $f(x)$
  • Emission: $g(x)$

And the dynamics of the model reduces to:

\[x_t | x_{t-1} \sim f(x_t | x_{t-1})\]

\[y_t | x_t \sim g(y_t | x_{t})\]

assuming $x_0 \sim f_0(x)$.

The joint law follows:

\[p(x_{0:T}, y_{0:T}) = f_0(x_0) \prod_t g(y_t | x_t) f(x_t | x_{t-1})\]

Model users can define their SSM using the following interface:


-struct Model <: AbstractStateSpaceModel end
+Home · SSMProblems

SSMProblems

Installation

In the julia REPL:

]add SSMProblems

Documentation

SSMProblems 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.

Consider a markovian model from[Murray]: state space model

The model is fully specified by the following densities:

  • Initialisation: $f_0(x)$
  • Transition: $f(x)$
  • Emission: $g(x)$

And the dynamics of the model reduces to:

\[\begin{aligned} +x_t | x_{t-1} &\sim f(x_t | x_{t-1}) \\ +y_t | x_t &\sim g(y_t | x_{t}) +\end{aligned}\]

assuming $x_0 \sim f_0(x)$.

The joint law follows:

\[p(x_{0:T}, y_{0:T}) = f_0(x_0) \prod_t g(y_t | x_t) f(x_t | x_{t-1})\]

Users can define their SSM with SSMProblems in the following way:

struct Model <: AbstractStateSpaceModel end
 
 # Define the structure of the latent space
 particleof(::Model) = Float64
@@ -36,4 +38,4 @@
         particles[i] = transition!!(rng, t, model, particles[i])
         logweights[i] += emission_logdensity(t, model, particles[i])
     end
-end

Interface

SSMProblems.emission_logdensityFunction
emission_logdensity(model, timestep, state, observation[, cache])

Compute the log potential of the current particle. This effectively "reweight" each particle.

source
SSMProblems.transition!!Function
transition!!(rng, model[, timestep, state, cache])

Simulate the particle for the next time step from the forward dynamics.

source
SSMProblems.transition_logdensityFunction
transition_logdensity(model, timestep, prev_state, next_state[, cache])

(Optional) Computes the log-density of the forward transition if the density is available.

source
  • Murray

    Murray, Lawrence & Lee, Anthony & Jacob, Pierre. (2013). Rethinking resampling in the particle filter on graphics processing units.

+end

Interface

SSMProblems.emission_logdensityFunction
emission_logdensity(model, state, observation[, timestep, cache])

Compute the log potential of the current particle. This effectively "reweight" each particle.

source
SSMProblems.linearizeMethod
linearize(particle)

Return the trace of a particle, i.e. the sequence of states from the root to the particle.

source
SSMProblems.transition!!Function
transition!!(rng, model[, timestep, state, cache])

Simulate the particle for the next time step from the forward dynamics.

source
SSMProblems.transition_logdensityFunction
transition_logdensity(model, prev_state, current_state[, timestep, cache])

(Optional) Computes the log-density of the forward transition if the density is available.

source
  • Murray

    Murray, Lawrence & Lee, Anthony & Jacob, Pierre. (2013). Rethinking resampling in the particle filter on graphics processing units.

diff --git a/previews/PR16/search/index.html b/previews/PR16/search/index.html index 3b6895c..b9f9547 100644 --- a/previews/PR16/search/index.html +++ b/previews/PR16/search/index.html @@ -1,2 +1,2 @@ -Search · SSMProblems

Loading search...

    +Search · SSMProblems

    Loading search...

      diff --git a/previews/PR16/search_index.js b/previews/PR16/search_index.js index 28c8b96..d460a72 100644 --- a/previews/PR16/search_index.js +++ b/previews/PR16/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"#SSMProblems","page":"Home","title":"SSMProblems","text":"","category":"section"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"In the julia REPL:","category":"page"},{"location":"","page":"Home","title":"Home","text":"]add SSMProblems","category":"page"},{"location":"#Documentation","page":"Home","title":"Documentation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"SSMProblems 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.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Consider a markovian model from[Murray]: (Image: state space model)","category":"page"},{"location":"","page":"Home","title":"Home","text":"[Murray]: Murray, Lawrence & Lee, Anthony & Jacob, Pierre. (2013). Rethinking resampling in the particle filter on graphics processing units. ","category":"page"},{"location":"","page":"Home","title":"Home","text":"The model is fully specified by the following densities:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Initialisation: f_0(x)\nTransition: f(x)\nEmission: g(x)","category":"page"},{"location":"","page":"Home","title":"Home","text":"And the dynamics of the model reduces to:","category":"page"},{"location":"","page":"Home","title":"Home","text":"x_t x_t-1 sim f(x_t x_t-1)","category":"page"},{"location":"","page":"Home","title":"Home","text":"y_t x_t sim g(y_t x_t)","category":"page"},{"location":"","page":"Home","title":"Home","text":"assuming x_0 sim f_0(x). ","category":"page"},{"location":"","page":"Home","title":"Home","text":"The joint law follows:","category":"page"},{"location":"","page":"Home","title":"Home","text":"p(x_0T y_0T) = f_0(x_0) prod_t g(y_t x_t) f(x_t x_t-1)","category":"page"},{"location":"","page":"Home","title":"Home","text":"Model users can define their SSM using the following interface:","category":"page"},{"location":"","page":"Home","title":"Home","text":"\nstruct Model <: AbstractStateSpaceModel end\n\n# Define the structure of the latent space\nparticleof(::Model) = Float64\ndimension(::Model) = 2\n\nfunction transition!!(\n rng::Random.AbstractRNG, \n step, \n model::Model, \n particle::AbstractParticl{<:AbstractStateSpaceModel}\n) \n if step == 1\n ... # Sample from the initial density\n end\n ... # Sample from the transition density\nend\n\nfunction emission_logdensity(step, model::Model, particle::AbstractParticle) \n ... # Return log density of the model at *time* `step`\nend\n\nisdone(step, model::Model, particle::AbstractParticle) = ... # Stops the state machine\n\n# Optionally, if the transition density is known, the model can also specify it\nfunction transition_logdensity(step, prev_particle::AbstractParticle, next_particle::AbstractParticle)\n ... # Scores the forward transition at `x`\nend","category":"page"},{"location":"","page":"Home","title":"Home","text":"Package users can then consume the model logdensity through calls to emission_logdensity. ","category":"page"},{"location":"","page":"Home","title":"Home","text":"For example, a bootstrap filter targeting the filtering distribution p(x_t y_0t) using N particles would roughly follow:","category":"page"},{"location":"","page":"Home","title":"Home","text":"struct Particle{T<:AbstractStateSpaceModel} <: AbstractParticle{T} end \n\nwhile !all(map(particle -> isdone(t, model, particles), particles)):\n ancestors = resample(rng, logweigths)\n particles = particles[ancestors]\n for i in 1:N\n particles[i] = transition!!(rng, t, model, particles[i])\n logweights[i] += emission_logdensity(t, model, particles[i])\n end\nend","category":"page"},{"location":"#Interface","page":"Home","title":"Interface","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Modules = [SSMProblems]\nOrder = [:type, :function]","category":"page"},{"location":"#SSMProblems.AbstractStateSpaceModel","page":"Home","title":"SSMProblems.AbstractStateSpaceModel","text":"AbstractStateSpaceModel\n\n\n\n\n\n","category":"type"},{"location":"#SSMProblems.emission_logdensity","page":"Home","title":"SSMProblems.emission_logdensity","text":"emission_logdensity(model, timestep, state, observation[, cache])\n\nCompute the log potential of the current particle. This effectively \"reweight\" each particle.\n\n\n\n\n\n","category":"function"},{"location":"#SSMProblems.transition!!","page":"Home","title":"SSMProblems.transition!!","text":"transition!!(rng, model[, timestep, state, cache])\n\nSimulate the particle for the next time step from the forward dynamics.\n\n\n\n\n\n","category":"function"},{"location":"#SSMProblems.transition_logdensity","page":"Home","title":"SSMProblems.transition_logdensity","text":"transition_logdensity(model, timestep, prev_state, next_state[, cache])\n\n(Optional) Computes the log-density of the forward transition if the density is available.\n\n\n\n\n\n","category":"function"}] +[{"location":"#SSMProblems","page":"Home","title":"SSMProblems","text":"","category":"section"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"In the julia REPL:","category":"page"},{"location":"","page":"Home","title":"Home","text":"]add SSMProblems","category":"page"},{"location":"#Documentation","page":"Home","title":"Documentation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"SSMProblems 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.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Consider a markovian model from[Murray]: (Image: state space model)","category":"page"},{"location":"","page":"Home","title":"Home","text":"[Murray]: Murray, Lawrence & Lee, Anthony & Jacob, Pierre. (2013). Rethinking resampling in the particle filter on graphics processing units. ","category":"page"},{"location":"","page":"Home","title":"Home","text":"The model is fully specified by the following densities:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Initialisation: f_0(x)\nTransition: f(x)\nEmission: g(x)","category":"page"},{"location":"","page":"Home","title":"Home","text":"And the dynamics of the model reduces to:","category":"page"},{"location":"","page":"Home","title":"Home","text":"beginaligned\nx_t x_t-1 sim f(x_t x_t-1) \ny_t x_t sim g(y_t x_t)\nendaligned","category":"page"},{"location":"","page":"Home","title":"Home","text":"assuming x_0 sim f_0(x). ","category":"page"},{"location":"","page":"Home","title":"Home","text":"The joint law follows:","category":"page"},{"location":"","page":"Home","title":"Home","text":"p(x_0T y_0T) = f_0(x_0) prod_t g(y_t x_t) f(x_t x_t-1)","category":"page"},{"location":"","page":"Home","title":"Home","text":"Users can define their SSM with SSMProblems in the following way:","category":"page"},{"location":"","page":"Home","title":"Home","text":"struct Model <: AbstractStateSpaceModel end\n\n# Define the structure of the latent space\nparticleof(::Model) = Float64\ndimension(::Model) = 2\n\nfunction transition!!(\n rng::Random.AbstractRNG, \n step, \n model::Model, \n particle::AbstractParticl{<:AbstractStateSpaceModel}\n) \n if step == 1\n ... # Sample from the initial density\n end\n ... # Sample from the transition density\nend\n\nfunction emission_logdensity(step, model::Model, particle::AbstractParticle) \n ... # Return log density of the model at *time* `step`\nend\n\nisdone(step, model::Model, particle::AbstractParticle) = ... # Stops the state machine\n\n# Optionally, if the transition density is known, the model can also specify it\nfunction transition_logdensity(step, prev_particle::AbstractParticle, next_particle::AbstractParticle)\n ... # Scores the forward transition at `x`\nend","category":"page"},{"location":"","page":"Home","title":"Home","text":"Package users can then consume the model logdensity through calls to emission_logdensity. ","category":"page"},{"location":"","page":"Home","title":"Home","text":"For example, a bootstrap filter targeting the filtering distribution p(x_t y_0t) using N particles would roughly follow:","category":"page"},{"location":"","page":"Home","title":"Home","text":"struct Particle{T<:AbstractStateSpaceModel} <: AbstractParticle{T} end \n\nwhile !all(map(particle -> isdone(t, model, particles), particles)):\n ancestors = resample(rng, logweigths)\n particles = particles[ancestors]\n for i in 1:N\n particles[i] = transition!!(rng, t, model, particles[i])\n logweights[i] += emission_logdensity(t, model, particles[i])\n end\nend","category":"page"},{"location":"#Interface","page":"Home","title":"Interface","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Modules = [SSMProblems]\nOrder = [:type, :function]","category":"page"},{"location":"#SSMProblems.AbstractStateSpaceModel","page":"Home","title":"SSMProblems.AbstractStateSpaceModel","text":"AbstractStateSpaceModel\n\n\n\n\n\n","category":"type"},{"location":"#SSMProblems.emission_logdensity","page":"Home","title":"SSMProblems.emission_logdensity","text":"emission_logdensity(model, state, observation[, timestep, cache])\n\nCompute the log potential of the current particle. This effectively \"reweight\" each particle.\n\n\n\n\n\n","category":"function"},{"location":"#SSMProblems.linearize-Union{Tuple{SSMProblems.Particle{T}}, Tuple{T}} where T","page":"Home","title":"SSMProblems.linearize","text":"linearize(particle)\n\nReturn the trace of a particle, i.e. the sequence of states from the root to the particle.\n\n\n\n\n\n","category":"method"},{"location":"#SSMProblems.transition!!","page":"Home","title":"SSMProblems.transition!!","text":"transition!!(rng, model[, timestep, state, cache])\n\nSimulate the particle for the next time step from the forward dynamics.\n\n\n\n\n\n","category":"function"},{"location":"#SSMProblems.transition_logdensity","page":"Home","title":"SSMProblems.transition_logdensity","text":"transition_logdensity(model, prev_state, current_state[, timestep, cache])\n\n(Optional) Computes the log-density of the forward transition if the density is available.\n\n\n\n\n\n","category":"function"}] }