Skip to content

Conversation

FredericWantiez
Copy link
Member

No description provided.

@charlesknipp
Copy link
Member

Love seeing this PR back in the rotation.

Instead of changing the mutability of the filter, we could instead dispatch on an Auxiliary callback.

struct AuxiliaryWeightCallback{WT} <: AbstractCallback
    log_weights::Vector{WT}
end

where we can replace update_weights! with a post update callback

function (aux::AuxiliaryWeightCallback)(
    model, algo, iter, state, observation, ::PostUpdateCallback; kwargs...
)
    aux.log_weights = map(state.particles) do particle
        logeta(particle, model, iter, observation; kwargs...)
    end
    state.log_weights += aux.log_weights
    return nothing
end

and replace reset_weights! with a post resample callback

function (aux::AuxiliaryWeightCallback)(
    model, algo, iter, state, observation, ::PostResampleCallback; kwargs...
)
    state.log_weights = state.log_weights - aux.log_weights[state.ancestors]
    return nothing
end

I haven't figured out a good way to dispatch filter with this particular callback built in, but ideally I'd still like to keep the filter(rng, model, APF(N), data) syntax. Although I'm sure it's not that difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants