BaytesFilters

Documentation for BaytesFilters.

BaytesFilters.InitialTrajectoryType
struct InitialTrajectory{K<:ParticleKernel, C<:ParticleReferencing, M<:ParticleFilterMemory}

Contains information to obtain reference trajectory for sampling process.

Fields

  • kernel::ParticleKernel

    Kernel for particle propagation

  • referencing::ParticleReferencing

    Referencing method

  • memory::ParticleFilterMemory

    Memory for observed and latent data in PF.

BaytesFilters.MarkovType
struct Markov{A, B, C} <: ParticleKernel

Markov Kernel for particle propagation.

Fields

  • initial::Any

    Initial distribution, function of iter only.

  • transition::Any

    Transition distribution, function of full particle trajectory and current iteration count.

  • evidence::Any

    Data distribution to weight particles. Function of full data, particle trajectory and current iteration count.

BaytesFilters.ParticleBufferType
struct ParticleBuffer{A, I, P}

Contains temporary buffer values to avoid allocations during particle propagation.

Fields

  • parameter::BaytesCore.ParameterBuffer{A, I} where {A, I}

    Contains buffer values for particles and ancestor for one iteration.

  • proposal::Vector

    Proposal trajectory and predicted latent variable.

  • prediction::Vector

    Predicted latent and oberved data

  • resampled::Vector{Bool}

    Stores boolean if resampled at each iteration.

  • ℓobjectiveᵥ::Vector{Float64}

    Stores incremental log target estimates for each iteration.

BaytesFilters.ParticleFilterType
struct ParticleFilter{A<:Particles, B<:ParticleFilterTune} <: BaytesCore.AbstractAlgorithm

Contains particles, transition kernel and all other relevant tuning information for particle propagation.

Fields

  • particles::Particles

    Particle values and kernel.

  • tune::ParticleFilterTune

    Tuning configuration for particles.

BaytesFilters.ParticleFilterConfigType
mutable struct ParticleFilterConfig{A, B, C, D}

Holds information for array structure of data and reference particle.

Fields

  • data::BaytesCore.ArrayConfig{A, B} where {A, B}

    Data size and sorting information.

  • particle::BaytesCore.ArrayConfig{C, D} where {C, D}

    Particle size and sorting information.

BaytesFilters.ParticleFilterDefaultType
struct ParticleFilterDefault{M<:Union{Nothing, ParticleFilterMemory}, A<:ParameterWeighting, B<:ResamplingMethod, C<:ParticleReferencing, T<:Integer, I<:AbstractInitialization, U<:UpdateBool}

Default arguments for Particle Filter constructor.

Fields

  • memory::Union{Nothing, ParticleFilterMemory}

    Memory for particles and data.

  • weighting::ParameterWeighting

    Weighting Methods for particles.

  • resampling::ResamplingMethod

    Resampling methods for particle trajectories.

  • referencing::ParticleReferencing

    Referencing type for last particle at each iteration - either Conditional, Ancestral or Marginal Implementation.

  • coverage::Float64

    Coverage of Particles/datapoints.

  • threshold::Float64

    ESS threshold for resampling particle trajectories.

  • ancestortype::Type{T} where T<:Integer

    Type for ancestors indices

  • init::AbstractInitialization

    Method to obtain initial Modelparameter, see 'AbstractInitialization'.

  • generated::UpdateBool

    Boolean if generate(_rng, objective) for corresponding model is stored in PF Diagnostics.

BaytesFilters.ParticleFilterMemoryType
struct ParticleFilterMemory

Contains maximum memory for latent and observed data. Relevant for number of propagation steps from initial particle distribution and for first time particles are weighted with data point.

Fields

  • latent::Int64

    Latent variable memory. Number of times that initial particle distribution is used.

  • data::Int64

    Observed data memory. First particle weighting taken at this point.

  • initial::Int64

    Number of times when sampled from initial distribution. Per default equal to latent.

BaytesFilters.ParticleFilterTuneType
struct ParticleFilterTune{T<:ModelWrappers.Tagged, A<:ParameterWeighting, B<:ResamplingMethod, C<:ParticleReferencing, D, E, F, G, U<:UpdateBool} <: BaytesCore.AbstractTune

Holds tuning information for Particle Filter.

Fields

  • tagged::ModelWrappers.Tagged

    Tagged Model parameter.

  • weighting::ParameterWeighting

    Weighting Methods for particles.

  • resampling::ResamplingMethod

    Resampling methods for particle trajectories.

  • referencing::ParticleReferencing

    Referencing type for last particle at each iteration - either Conditional, Ancestral or Marginal Implementation.

  • config::BaytesFilters.ParticleFilterConfig

    Contains data and reference size and sorting.

  • chains::BaytesCore.ChainsTune

    Number of particle chains and tuning information.

  • memory::ParticleFilterMemory

    Memory for latent and observed data.

  • generated::UpdateBool

    Boolean if generated quantities should be generated while sampling

  • iter::BaytesCore.Iterator

    Current iteration.

BaytesFilters.ParticlesType
mutable struct Particles{R, B, I<:Integer} <: AbstractParticles

Contains Particle container for propagation.

Fields

  • val::ElasticArrays.ElasticArray{B, 2, 1, Vector{B}} where B

    Particle trajectories, for a discussion about possible shapes for the trajectories.

  • ancestor::ElasticArrays.ElasticArray{I, 2, 1, Vector{I}} where I<:Integer

    Saved ancestors of resampling step in pf

  • weights::BaytesCore.ParameterWeights

    Particle weights.

  • buffer::ParticleBuffer{B, I, R} where {R, B, I<:Integer}

    Necessary buffer values for resampling particles.

  • ℓobjective::BaytesCore.Accumulator

    Log likelihood estimate.

BaytesFilters.SemiMarkovType
struct SemiMarkov{A<:SemiMarkovInitiation, B<:SemiMarkovTransition, C} <: ParticleKernel

Semi-Markov Kernel for particle propagation.

Fields

  • initial::SemiMarkovInitiation

    Initial distribution, function of iter only.

  • transition::SemiMarkovTransition

    Transition distribution, function of full particle trajectory and current iteration count.

  • evidence::Any

    Data distribution to weight particles. Function of full data, particle trajectory and current iteration count.

BaytesFilters.SemiMarkovInitiationType
struct SemiMarkovInitiation{A, B}

Initial distribution for state and duration of semi-Markov kernel.

Fields

  • state::Any

    Initial distribution of state variable.

  • duration::Any

    Initial distribution of duration variable.

BaytesFilters.SemiMarkovTransitionType
struct SemiMarkovTransition{A, B}

Transition distributions for state and duration of semi-Markov kernel.

Fields

  • state::Any

    Transition distribution of state variable.

  • duration::Any

    Transition distribution of duration variable.

Base.resize!Method
resize!(particles, reference, Nparticles, Ndata)

Resize particles struct with new Nparticles and Ndata size.

Examples

BaytesCore.generateMethod
generate(_rng, algorithm, objective)

Generate statistics for algorithm given model parameter and data.

Examples

BaytesCore.inferMethod
infer(_rng, kernel, tune, model, data)

Infer type of predictions of kernel.

Examples

BaytesCore.inferMethod
infer(_rng, diagnostics, pf, model, data)

Infer ParticleFilter diagnostics type.

Examples

BaytesCore.propagate!Method
propagate!(_rng, objective, length_forecast)

Propagate forward a single trajectory given ParticleKernel and objective for multiple time steps.

Examples

BaytesCore.propagateMethod
propagate(_rng, kernel, memory, reference)

Propagate forward a single trajectory given ParticleKernel.

Examples

BaytesCore.propose!Method
propose!(_rng, pf, model, data)
propose!(_rng, pf, model, data, proposaltune)

Run particle filter and change reference trajectory with proposal trajectory.

Examples

BaytesCore.proposeMethod
propose(_rng, kernel, pf, objective)
propose(_rng, kernel, pf, objective, reference)

Run particle filter and do not change reference trajectory.

Examples

BaytesCore.resample!Method
resample!(_rng, kernel, particles, tune, reference)

Resample particle ancestors and shuffle current particles dependency.

Examples

BaytesCore.resultsMethod
results(diagnosticsᵛ, pf, Ndigits, quantiles)

Return summary statistics for PF diagnostics.

Examples

BaytesCore.update!Method
update!(particles, ParticleUpdate, DataUpdate, reference, Nparticles, Ndata)

Update particles struct with new number of particles. Note that kernel and log likelihood are adjusted in another step.

Examples

BaytesFilters.ancestors!Method
ancestors!(_rng, referencing, resampling, ancestor, iter, Nparticles, weights)

Resampling function for particles, dispatched on ParticleReferencing subtype.

Examples

BaytesFilters.assign!Method
assign!(buffer, trajectory)

Assign 'trajectory' elements to 'buffer' up until index 'iter'.

Examples

BaytesFilters.dynamics_propagateMethod
dynamics_propagate(objective)

Setup dynamics for propagate!() step. By default, same as dynamics_propose, but can be extended if faster setup is available.

Examples

BaytesFilters.estimate_NparticlesMethod
estimate_Nparticles(_rng, pf, objective, variance)

Function that checks for number of particles to achieve target variance of log target estimate.

Examples

BaytesFilters.get_reference!Method
get_reference!(_rng, kernel, referencing, ancestor, particles, tune, reference)

Compute new reference index from current reference index.

Examples

BaytesFilters.get_referenceMethod
get_reference(referencing, model, data, tagged)

Assign reference, depending on whether reference is tracked in Model.

Examples

BaytesFilters.imputeMethod
impute(data, t, kernel, particles, tune, reference, objective)

Extendable function to work with missing data

Examples

BaytesFilters.initial!Method
initial!(_rng, kernel, val, iter)

Inplace initiate particle given kernel.

Examples

BaytesFilters.initial!Method
initial!(_rng, kernel, particles, tune, reference, objective)

Initialize particles.

Examples

BaytesFilters.initialMethod
initial(_rng, kernel)

Initiate particle with given initial distribution.

Examples

BaytesFilters.sample_ancestorMethod
sample_ancestor(_rng, kernel, weights, valₜ, val, iter)

Sample ancestor reference for particle history.

Examples

BaytesFilters.ℓevidence!Method
ℓevidence!(kernel, ℓcontainer, dataₜ, val, iter)

Inplace logpdf evaluation of data given current particle trajectory.

Examples

BaytesFilters.ℓtransition!Method
ℓtransition!(kernel, ℓcontainer, valₜ, val, iter)

Inplace calculate log transtion probability from current particle given trajectory.

Examples

BaytesFilters.ℓtransitionMethod
ℓtransition(kernel, valₜ, val, iter)

Calculate log transtion probability from particle given particle history.

Examples

ModelWrappers.predictMethod
predict(_rng, kernel, trajectory, reference, iter)

Predict new latent and observed data.

Examples